I'm still adding content to this guide, so please be patient
I've been spending a fair amount lately playing around with running PowerShell scripts that are saved on the internet and I thought it would be helpful to share what I have leared on this ... so this guide will be focused on executing PowerShell scripts that are saved on the Internet, what I call a PSCloudScript


The method for running a PowerShell script on the internet is to get the raw content of a URL using Invoke-RestMethod, and then execute the result using Invoke-Expression
Invoke-RestMethod -Uri $Uri | Invoke-Expression
The following command lines are identical to the method above, just formatted differently. My preference is iex(irm $Uri) as it is short and works for both PowerShell and CMD with minimal effort
#full command
Invoke-Expression -Command (Invoke-RestMethod -Uri $Uri)
#using alias
iex(irm $Uri)
Invoke-RestMethod -Uri $Uri | Invoke-Expression
#pipeline using alias
irm $Uri | iex
Command Prompt
rem full command
powershell Invoke-Expression -Command (Invoke-RestMethod -Uri $Uri)
rem using alias
powershell iex(irm $Uri)

KeyVault Secret Method

I'm jumping ahead here, but here is the command line for executing a PowerShell script saved as an Azure Key Vault Secret
iex(AzKeyVaultSecret $VaultName $SecretName -As)


OSDeploy is sponsored by Recast Software and their Systems Management Tools
Recast Software
Sponsored by Recast Software