Created
July 23, 2012 03:23
-
-
Save grassdog/3161871 to your computer and use it in GitHub Desktop.
Script for downloading a Powerhell script via a proxy and executing it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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