Last active
April 20, 2021 15:07
-
-
Save yujp/b184be7f364f2a67e7ec687655df32d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Add-Type -AssemblyName System.Net.Http | |
# proxy | |
$bypassOnLocal = $TRUE | |
$proxy = [System.Net.WebRequest]::GetSystemWebProxy() | |
#$proxy = New-Object System.Net.WebProxy("http://localhost:8888", $bypassOnLocal) | |
#$proxy.Credentials = [System.Net.CredentialCache].DefaultNetworkCredentials | |
#$proxy.Credentials = New-Object System.Net.NetworkCredential("username", "password") | |
$password = ConvertTo-SecureString "password" -asplaintext -force | |
$cred = New-Object System.Management.Automation.PsCredential "username",$password | |
#$proxy.Credentials = $cred | |
#[System.Net.WebRequest]::DefaultWebProxy = $proxy | |
# show the proxy URL | |
$proxy.GetProxy('https://google.com') | Select -ExpandProperty OriginalString | |
$h = New-Object System.Net.Http.HttpClientHandler | |
$h.UseProxy = $TRUE | |
$h.Proxy = $proxy | |
#$h.Credentials = | |
$h.PreAuthenticate = $TRUE | |
$h.UseDefaultCredentials = $TRUE | |
$h.UseCookies = $TRUE | |
#$h.DefaultProxyCredentials = | |
$url = "https://www.google.com/" | |
(New-Object System.Net.Http.HttpClient($h)).GetAsync($url) | |
(New-Object System.Net.Http.HttpClient).GetAsync($url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment