Following PsGet example, this is how I run a ps1 from an url:
(new-object Net.WebClient).DownloadString($Url) | iex
Now, it would be great if I could pass parameters to that script in a one liner like this, but any parameters I pass go to iex
instead of getting passed to the script.
How can it be done in a one line? Perhaps it can have two chained commands, but three commands is already too much for a one line.
您可以从字符串创建未命名的脚本块,然后使用调用运算符( &
)调用它:
& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString($Url))) -param1 argumentvalue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.