1

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.

Badb0y
  • 331
  • 2
  • 21

2 Answers2

3

You can always put statements in same line by separating them with semi-colon ;:

$webClient = New-Object System.Net.WebClient;$webClient.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy()
manojlds
  • 290,304
  • 63
  • 469
  • 417
2
iex ((New-Object Net.WebClient -Property @{Proxy = [Net.GlobalProxySelection]::GetEmptyWebProxy()}).DownloadString('https://githubxxxx/install.ps1'))
  • Thank you, that is that I want. – Badb0y Jun 22 '18 at 07:15
  • one more new thing come up, I want to run this script from rundeck job, and I need to somehow pass 2 arguments to the command, how can I pass these to my command: "${node.site}" "${node.zone}", I mean how can I define these 2 variables to the command that you've provided? In my script the param already defined. – Badb0y Jun 27 '18 at 04:46