连接 powershell 命令

Concatenate powershell commands

我想 运行 在 1 行中执行此命令:

$url = "https://githubxxxx/install.ps1"
$webClient = New-Object System.Net.WebClient 
$webClient.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy()
$webClient.DownloadString($url) | Invoke-Expression

应该和本文类似:

但我不知道如何放置这一行:

$webClient.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy()  

进入此命令:

iex ((New-Object System.Net.WebClient).DownloadString('https://githubxxxx/install.ps1'))  

我想要实现的 运行 它没有来自 github 的代理。

您始终可以将语句放在同一行,用分号分隔它们 ;:

$webClient = New-Object System.Net.WebClient;$webClient.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy()
iex ((New-Object Net.WebClient -Property @{Proxy = [Net.GlobalProxySelection]::GetEmptyWebProxy()}).DownloadString('https://githubxxxx/install.ps1'))