Skip to content

Instantly share code, notes, and snippets.

@pfmoore
Created December 15, 2014 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfmoore/8c8e7a0b80ee2d412657 to your computer and use it in GitHub Desktop.
Save pfmoore/8c8e7a0b80ee2d412657 to your computer and use it in GitHub Desktop.
Useful Powershell Snippets
# Use this one to load this snippet :-)
function Invoke-URLContent ($url) {
(New-Object Net.WebClient).DownloadString($url) | Invoke-Expression
}
function Get-URLContent ($url, $path) {
if (!$path) {
$path = Join-Path $pwd.Path ([URI]$url).Segments[-1]
}
(New-Object Net.WebClient).DownloadFile($url, $path)
}
# Need to run this once if your connection needs proxy authentication
function Set-ProxyAuthentication {
$wc = New-Object Net.WebClient
$wc.UseDefaultCredentials = $true
$wc.Proxy.Credentials = $wc.Credentials
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment