Install PowerShell Modules behind proxy

Ackles
Ackles used Ask the Experts™
on
Hello,
I have to install powershell modules of Exchange Online, SharePoint Online, Azure ....

I can manually download these modules & install them, however the issue is that I need them on more than one server .
I have the servers behind the proxy.

When I run Install-module -name .... I get the following error:
The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags......

Can someone help me get over this error & let me know how to resolve this issue?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Anyone
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Did you configure the proxy settings? You should use the net command, here's how to get the current proxy config:

netsh winhttp show proxy

Open in new window

Author

Commented:
Current WinHTTP proxy settings:

    Direct access (no proxy server).

However in IE the proxy is set
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
IE doesnt matter, you need to configure the winhttp proxy setting, as this is what PowerShell uses.

Author

Commented:
In that case these are the settings, what should I do?
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You should configure them via the net command, as I already mentioned above. Here's an example:

netsh winhttp set proxy "192.168.0.1:8080"

For more examples, refer to the tool help.

Author

Commented:
The winrm config is :

winrm get winrm/config/client
Client
    NetworkDelayms = 5000
    URLPrefix = wsman
    AllowUnencrypted = false [Source="GPO"]
    Auth
        Basic = false [Source="GPO"]
        Digest = false [Source="GPO"]
        Kerberos = true
        Negotiate = true
        Certificate = true
        CredSSP = false
    DefaultPorts
        HTTP = 5985
        HTTPS = 5986
    TrustedHosts = *

Author

Commented:
Ok, I set the proxy & now it shows Proxy Server in list
However, when I try
New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication "Basic" -AllowRedirection

I get error:

New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following
error message : The WinRM client cannot process the request. Basic authentication is currently disabled in the client
configuration. Change the client configuration and try the request again. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:13
+ $exchange = New-PSSession -ConfigurationName Microsoft.Exchange -Conn ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : -2144108321,PSSessionOpenFailed
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Look at your WinRM config aou oisted, it clearly states that you cannot use Basic, Digest or CredSSP for authentication. Use Negotiate, that should work.

Author

Commented:
Error with Negotiate


New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:13
+ $exchange = New-PSSession -ConfigurationName Microsoft.Exchange -Conn ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
   gTransportException
    + FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Basic auth is a requirement when you're connecting to ExO, so you need to have this sorted with your admins (or override the GPO yourself, assuming you have local admin privileges).

Author

Commented:
I can override, could you guide me in the direction....

Author

Commented:
I've set the registry value to 1: HKLM\SOFTWARE\POLICIES\MICROSOFT\WINDOWS\WINRM\SERVICE\ALLOWBASIC

but in Powershell it still shows the same result
winrm get winrm/config/client
Client
    NetworkDelayms = 5000
    URLPrefix = wsman
    AllowUnencrypted = false [Source="GPO"]
    Auth
        Basic = false [Source="GPO"]
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
Just delete the key. Or set it directly via PowerShell:

PS C:\> cd WSMan:
PS WSMan:\> cd .\localhost\Client\Auth
PS WSMan:\localhost\Client\Auth> set-Item basic $true

Open in new window

Author

Commented:
throws error : the config setting Basic can't be changed, set by policy....

Even if I'm localadmin, can't be changed
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
Then you might have to stop the GPO from getting applied against your machine ...

Author

Commented:
If I could, why would I do the whole practice .....
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
If you could, you would be able and allowed to do (make changes to GPOs).

But it is time now to make this a different question. The original issue of setting up using a proxy for installing PS modules is resolved, you now have issues with running the individual modules.

Author

Commented:
I didn't realize this was Microsoft Support.....
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Well we cannot really help you bypass restrictions set by your domain admins. In general, if you are a local admin on the device, you can overwrite the policy settings, but this will only apply until the next time policies are processed. So best talk to your admins, or use a machine that doesnt have such restrictions.

Author

Commented:
no worries, Thanks a lot!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial