Wednesday, August 29, 2018

Get-SPWeb can't find the site you were looking for

Error:
PS C:\Windows\system32> Get-SPWeb -Identity "https://mysite.com/docs/"
Get-SPWeb : Cannot find an SPSite object that contains the following Id or Url: https://mysite.com/docs/.

Fix:
In the Front-End machine(s) restart the application pool "SecurityTokenServiceApplicationPool".

Sign In As Different User Option In SharePoint 2016

On the front-end server(s) open file "Welcome.ascx", located at "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\TEMPLATE\CONTROLTEMPLATES".

Find the block with the content:
<SharePoint:MenuItemTemplate runat="server" id="ID_PersonalInformation"
Text="<%$Resources:wss,personalactions_personalinformation%>"
Description="<%$Resources:wss,personalactions_personalinformationdescription%>"
MenuGroupId="100"
Sequence="100"
ImageUrl="/_layouts/15/images/menuprofile.gif?rev=40"
UseShortId="true"
/> 

and add this on the next row:
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" 
Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" 
Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" 
MenuGroupId="100" 
Sequence="100" 
UseShortId="true" />

NB! The change must be made on every front-end server and always back-up!