Search code examples
powershellinvoke-command

Concatenate powershell commands


I'd like to run this commands in 1 line:

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

It should be similar to this article:
Run Powershell script from URL without temporary file

But I have no idea how to put this line:

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

into this command:

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

What I want to achieve run it without proxy from github.


Solution

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