Run a PowerShell script from a local or remote path.
- PowerShell v5
Runs the PowerShell script 'C:\Users\User\Restart-MyComputer.ps1'.
Invoke-Script -Uri 'C:\Users\User\Restart-MyComputer.ps1'
Downloads and runs the PowerShell script 'Set-UserWallpaper.ps1', passing the given parameters to it.
Invoke-Script -Uri 'https://file.contoso.com/scripts/Set-UserWallpaper.ps1' -Parameters @{
User = 'Joe.Smith'
Wallpaper = 'https://static.wikia.nocookie.net/vocaloid/images/5/57/Miku_v4_bundle_art.png'
}
Parameter | Required | Default | Type | Description |
---|---|---|---|---|
Uri |
True | System.URI | The local path or URL of the target PowerShell script. | |
Parameters |
False | hashtable | A hashtable of parameters to pass to the target PowerShell script. |
This function will have varying output based on the called PowerShell script.