Web Interaction

Aliases -> iwr, wget, curl.

Requests

# Sending a GET request
Invoke-WebRequest -Method GET -Uri <uri>
# Inspect the object's output methods and properties
Invoke-WebRequest -Method GET -Uri <uri> | Get-Member
# Filtering the GET request -> listing the page's images
IWR -Method Get -Uri <uri> | fl Images
# Filtering raw content
IWR -Method Get -Uri <uri> | fl RawContent

Downloads

# Downloading a file
IWR -Uri <uri> -OutFile <C:\file-name>

An alternative if IWR cannot be used; this is a .NET class.

# Donwnloading a file
(New-Object Net.WebClient).DownloadFile("<uri>", "<file-name>")

Last updated