msiexec /a C:\path\to\the.msi TARGETDIR=C:\path\to\extraction\dir\ /qn
Check if the server is hosted on Google Cloud or AWS
- AWS
curl -Lso /dev/null http://169.254.169.254/latest/meta-data && echo "Definitely AWS"
if ((IWR -URI http://169.254.169.254/latest/meta-data -UseBasicParsing) -ne $null) { echo "Definitely AWS" }
- GCN
curl -Lso /dev/null -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/ && echo "Definitely GC"
PowerShell 3.0 or newer is required to send custom headers
if ((IWR -URI "http://metadata.google.internal/computeMetadata/v1/" -Headers @{"Metadata-Flavor"="Google"} -UseBasicParsing) -ne $null) { echo "Definitely GC" }
Show all TCP ports in “Listening” state and their owner processes
netstat -bonap tcp | Select-String "LISTENING" -Context 0,1
Show permissions for a file and all parent folders
function namei { If ( $args[0] -eq $null ) { $path = ($pwd).Path } Else { $path = $args[0] } If ( -not (Test-Path -Path $path) ) { echo "Path does not exist" return } While ( $path -ne "" ) { $acl = Get-ACL -Path $path echo $path "`r`n" ( $acl | Select -Property Owner,Group | FL | Out-String ).Trim() $acl | Select -Expand Access | Select -Property FileSystemRights,AccessControlType,IdentityReference,IsInherited | FT $path = $path | Split-Path } }
namei C:\Windows
Show permissions for a file and all parent folders
namei -om /etc/nginx/nginx.conf
Download a file via PowerShell
Invoke-WebRequest -URI https://google.com/favicon.ico -OutFile file.ico
A bit faster alternative with direct invokation of .NET classes
(New-Object System.Net.WebClient).DownloadFile("https://google.com/favicon.ico", "file.ico")
Check request timings using curl
(curl -s -w '\nLookup:\t%{time_namelookup}s\nConnect:\t%{time_connect}s\nPre-transfer:\t%{time_pretransfer}s\nTTFB:\t%{time_starttransfer}s\nTotal:\t%{time_total}s\n' -o /dev/null https://hub.from.support/) | column -t
Apply RegExp to IIS bindings
PowerShell WebAdministration module is required to run Get-Website cmdlet
Get-Website | Where-Object { $_.Bindings.Collection -match ".*8443.*" }
Move and overwrite all files in destination, including hidden
rsync is required
--dry-run
option might be used to check what actions will be performed by rsync, without actually running them
rsync -av --remove-source-files /src/ /dest/
List available IP addresses
hostname -I