MicrosoftDocs / PowerShell-Docs-PSGet

The official documentation for PowerShellGet and PowerShell Gallery
https://docs.microsoft.com/powershell/gallery/overview
Creative Commons Attribution 4.0 International
23 stars 24 forks source link

Get-InstalledModule Command Not Working Remotely #120

Closed PawarAjay8487 closed 7 months ago

PawarAjay8487 commented 7 months ago

Type of issue

Code doesn't work

Feedback

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

image

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

Somehow highlighted command in the below screenshot is not working when called remotely.

image

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

image

Page URL

https://learn.microsoft.com/en-us/powershell/module/powershellget/get-installedmodule?view=powershellget-3.x

Content source URL

https://github.com/MicrosoftDocs/PowerShell-Docs-PSGet/blob/main/powershell-gallery/powershellget-3.x/PowerShellGet/Get-InstalledModule.md

Author

@sdwheeler

Document Id

d5816093-327c-2598-9e58-7fd92e89e4a0

sdwheeler commented 7 months ago

I can see by the error message that you haven't updated the version of PowerShellGet and PackageManagement on the server. It shows you are using v1.0.0.1. That version is not supported and must be upgraded. See https://learn.microsoft.com/powershell/gallery/powershellget/update-powershell-51