The other day I upgraded a SharePoint 2016 Server Farm from Windows Server 2012 R2 to Windows Server 2019. The inline upgrade went quite nicely, and everything worked like a charm after the upgrade, minus one thing. The SharePoint Management Console was throwing an error upon startup, and the same error message appeared when starting a regular Powershell session.
Add-PsSnapin : No snap-ins have been registered for Windows PowerShell version 5. At C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\CONFIG\POWERSHELL\Registration\SharePoint.ps1:3 char:1 + Add-PsSnapin Microsoft.SharePoint.PowerShell + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.SharePoint.PowerShell:String) [Add-PSSna pin], PSArgumentException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
It seems that after the upgrade to Windows Server 2019, the Microsoft.SharePoint.PowerShell.dll was not registered with Windows, causing the error. However, it was quite easy to remedy this situation, by using InstallUtil to re-register the DLL.
PS C:\WINDOWS\system32> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /LogToConsole=true C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.PowerShell\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.PowerShell.dll
We have the same exact thing happening to our Exchange server since it was upgraded to 2019. Not sure which dll needs re-registered for that one. Any help by any chance? Appreciate your post. Not many people having this issue in the recent years!
Thank You Sir, This worked for me