Get-InstalledModule returns “System.DateTime” error
This one caught me off-guard when installing my PC with a fresh image of Windows 10.
The issue:
After installing a Module for PowerShell using Install-Module, I wanted to see all the installed modules with Get-InstalledModule. When I hit Enter, I got the following error message: Cannot convert null to type “System.DateTime”
Cause and solution:
The default version of PowerShellGet that’s installed can give you this error. What you should do to resolve this is install the latest version of PowerShellGet. Before you do this, you should update to the latests version of the NuGet Package Provider.
Steps to resolve:
Open a elevated PowerShell window and type the following lines:
Install-PackageProvider Nuget -Force
Install-Module -Name PowerShellGet -Force
After this, when you run Get-InstalledModule, the error should be gone.