Skip to content

Instantly share code, notes, and snippets.

@grassdog
Created July 23, 2012 03:23
Show Gist options
  • Save grassdog/3161871 to your computer and use it in GitHub Desktop.
Save grassdog/3161871 to your computer and use it in GitHub Desktop.
Script for downloading a Powerhell script via a proxy and executing it
param (
[Parameter(Mandatory=$true, HelpMessage='Provide a URL to download')]
$url
)
$proxy = new-object System.Net.WebProxy("http://myproxyaddress")
$username = 'myusername'
$password = ConvertTo-SecureString 'MyPass' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential $username, $password
$proxy.credentials = $cred
$webClient = new-object System.New.WebClient
$webClient.proxy = $proxy
$webClient.DownloadString($url) | invoke-expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment