Importing PowerShell Modules When You Cannot Install PowerShell Modules.

**Note: This article is written around a single PowerShell module (ExchangeOnlineManagement). However, the steps will work for any PowerShell module. Have at it! –MDG

PS C:\> Install-Module -Name ExchangeOnlineManagement

PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘ExchangeOnlineManagement’. Try Get-PSRepository to see all available registered module repositories.
At C:\program files\powershell\6\Modules\PowerShellGet\PSModule.psm1:9491 char:21
+ …          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PSI was at a loss. For the life of me I could not install a PowerShell module on a server. Let me clarify… I could not install any PowerShell module onto this server. It wasn’t only this one server either. I was working at a customer that had implemented a lot of security measures on their servers – not only proxies, although that was there too – and had not done a very good job of documenting these measures. Oh, and then the guy who built that secured image (on which at least ten servers that I need to work on are based) left the company.

I spoke with my contact who told me that they were planning on fixing all of the issues that the former administrator’s security had caused… it was on their list. How far down on the list? That he couldn’t answer me. “In the meantime, you’re a pretty clever guy… you’ll be able to find workarounds for most of what is blocking you… but you are not permitted to compromise the security.”

I spent a little time working on this one, and as I dug deeper into the rabbit hole, I decided that I did not need to fix the problem… and frankly, doing so would have compromised the security. I just needed to work my way around it. Here’s what I did:

1) On a clean system (that is not based on the locked-down image), I opened PowerShell and ran the following:

cd .\Users\mgarvis\Downloads\
save-module ExchangeOnlineManagement

This resulted in a directory structure being created in my Downloads directory that was about 27.5MB.

2) I opened a File Explorer window and navigated to the Downloads directory.

3) I opened a second File Explorer window and navigated to the Downloads folder on the server (\\servername\c$\Users\mgarvis\Downloads).

4) I copied the ExchangeOnlineManagement directory from the source into the destination.

5) Back on the server I needed to work on, I opened a PowerShell (Administrator) console and navigated to the C:\ (root).

6) I then ran the following cmdlet:

Import-Module C:\Users\mgarvis-admin\Downloads\ExchangeOnlineManagement

7) To check that it worked, I ran a simple Get- cmdlet: Get-Module –name ExchangeOnlineManagement. The result:


It worked! That’s all I needed… and it will work with any module. I hope this helps!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s