Get-InstalledModule Command Not Working Remotely

45 views Asked by At

There seems to be some issue with the PowerShell Command Get-InstalledModule. E.g When I log in locally to a Windows server (PowerShell 5.1) and execute command Get-InstalledModule -Name Az it works fine but when I remote into the same server using Enter-PSSession or New-PSSession and run the same command, it fails with the error can no convert null to a system.datetime enter image description here

On Further troubleshooting, we found that this seems to be an issue with the PowerShell psmodule.psm1 file.

Somehow highlited command in the below screenshot is not working when called remotely. enter image description here

Here are the lines in the psmodule.psm1 file which might be causing actual issue

enter image description here

has anyone faced this issue before?

1

There are 1 answers

2
Dennis On

What about using

Get-Module -Name Az -ListAvailable

or to get all modules that isn't built-in

Get-Module -ListAvailable | where RepositorySourceLocation