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

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.

Here are the lines in the psmodule.psm1 file which might be causing actual issue
has anyone faced this issue before?

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