Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created June 3, 2020 20:51
Show Gist options
  • Save NanoDano/37875f22fb6f00dfcbaaa294f2943522 to your computer and use it in GitHub Desktop.
Save NanoDano/37875f22fb6f00dfcbaaa294f2943522 to your computer and use it in GitHub Desktop.
Powershell make HTTP GET request

Windows PowerShell

Network wake on lan packet http://www.adminarsenal.com/admin-arsenal-blog/powershell-sending-a-wake-on-lan-wol-magic-packet/

System.Net.WebRequest -

$req = [System.Net.WebRequest]::Create('http://www.devdungeon.com') $req.Method ="GET" $req.ContentLength = 0 $resp = $req.GetResponse() $reader = new-object System.IO.StreamReader($resp.GetResponseStream()) $reader.ReadToEnd()

Invoke-WebRequest

$url = "http://www.devdungeon.com" $output = "test.html" $start_time = Get-Date

Invoke-WebRequest -Uri $url # Prints out metadata about the response

Invoke-WebRequest -Uri $url -OutFile $output Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment