I want to write a PowerShell script that runs a PowerShell script stored at a URL, passing both custom arguments and forwarding any arguments that are given to this PowerShell. Concretely, I can do:
$VAR=Invoke-WebRequest http://example.com/powershell.ps1
$TEMP=New-TemporaryFile
$FILE=$TEMP.FullName + ".ps1"
$VAR.Content | Out-File $FILE
& $FILE somearguments $args
I'd ideally like to do that without using a temporary file, however powershell -content -
doesn't seem to allow also passing arguments. Is there any way to avoid the temporary file?