PS Cmdlets
22.1.16
The two PowerShell Cmdlets that are used are Invoke-RestMethodand Invoke-Expression. It is also important that these cmdlets are processed in this order, which I will touch on at the bottom of this page
Invoke-RestMethod
This cmdlet is used to return the contents of a provided URL in a structured, typically Raw format
Here are some examples of how to use Invoke-RestMethod to get the raw content from a Url
Invoke-Expression
This cmdlet is used to execute a PowerShell Command. You can read Microsoft's documentation here
If you read the Microsoft Doc, you'll understand that iex commands can come from a String. This can be easily demonstrated in this example
This method even works if there is a PowerShell function in the String. Keep in mind this function is only available in the current PowerShell session
Order
These commands have to follow a specific order. You need the content from Invoke-RestMethod before you can execute in Invoke-Expression
Sponsor
OSDeploy is sponsored by Recast Software and their Systems Management Tools
Last updated
