Troubleshooting cmdlet(s)\module(s) on different machines

Sometimes, you can run into an issue where a cmdlet won’t run on a machine, but it is running fine on another machine. In that scenario the first thing to do is find out what module that cmdlet is from on the machine that’s running the cmdlet properly.

To do this, you would run the below command

Get-Command Install-Module | fl *

You’ll get a large export, but at the bottom of that export you’ll see a line similar to this:

ModuleName : PowerShellGet
Module : PowerShellGet

Now we know what that module is.

The next thing we can do is figure out where that module resides on the machine. You can run this command to get that information.

Get-Module PowerShellGet | fl *

Similar to the first command we ran, you’ll see a lot of exported data, but towards the bottom you will see this:

FileList : {C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1, C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSGet.Format.ps1xml, C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSGet.Resource.psd1}

Now you can see where that module resides, and we can copy that module folder from our working machine to our non-working machine.

In the example above I would copy the folder

C:\Program Files\WindowsPowerShell\Modules\PowerShellGet

into

C:\Program Files\WindowsPowerShell\Modules\

on the non-working machine.

After performing this, restart the powershell app/ISE and now the cmdlet(s) should work properly.