Using Proxy to Install-Module


Find-Module -Name PowerShellGet  # To look for a module

Find-Module -Name PowerShellGet | Install-Module # To look for a module and install that

Using Proxy to connect to Internet:

Import the proxy settings from Internet Explorer parameters:
netsh winhttp import proxy source=ie
or set them manually:
netsh winhttp set proxy "192.168.0.14:80"

To view current proxy setting:
netsh winhttp show proxy

To reset the winhttp proxy:
netsh winhttp reset proxy
If you are signed in using your domain account and your proxy supports NTLM/AD authentication, you can use the credentials of the current user to authenticate on the proxy server (you won’t have to enter your username/password):
$Wcl = new-object System.Net.WebClient
$Wcl.Headers.Add(“user-agent”, “PowerShell Script”)
$Wcl.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
If you have to authenticate on the proxy server manually, run the following commands and specify user name and password in the corresponding window.
$Wcl=New-Object System.Net.WebClient
$Creds=Get-Credential
$Wcl.Proxy.Credentials=$Creds
Try the following PowerShell code to access HTTPS website via proxy:
$Creds=Get-Credential
$proxy = New-Object System.Net.WebProxy
$proxy.Address = [uri]”http://yourproxy:80″
$proxy.Credentials = $Creds
[System.Net.WebRequest]::DefaultWebProxy = $proxy
Invoke-WebRequest -Uri “https://contoso.com”

Comments

Popular posts from this blog

vRA/vRO workflows

How to generate HPS Report for Windows