We recently did an in-place upgrade of our SharePoint servers (app and web) from Windows Server 2008 R2 to Windows Server 2012 R2. After the upgrade the UPS did not work and web applications failed with a message:
Could not load user profile
The SharePoint logs showed an issue with the security tokens among other things:
An exception occurred when trying to issue security token
This makes sense as the OS update would have changed some certificate keys etc. Tried the usual stop/start of services and IIS, confirmed all App Pools were working. Final fix was to re-provision service applications. This made me a bit nervous but turned out to be a quick PowerShell script to run:
$h = Get-SPServiceHostconfig
$h.Provision()
$services = Get-SPServiceApplication
foreach ($service in $services) { $service.provision(); write-host $service.name}
If you have issues opening the SharePoint libraries in Powershell for SharePoint 2010 then create below shortcut to force it to load SharePoint libraries:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit ” & ‘ C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1 ‘ “