Open PowerShell as a different user |
This is my blog about coding in C#. C# is what I do, so C# is what I am going to talk about.
Tuesday, May 23, 2017
Open PowerShell as another user
This comes up quite often if you play around with PowerShell and SharePoint. Just because you have Administrative rights in SharePoint, it doesn't follow that you can access a site programatically from PowerShell. For that, you need to be granted Shell Admin rights on the content database that holds the site. There are some accounts in SharePoint that are more privileged than others, and the farm account is one of those. What you can do, assuming that you know the farm account credentials, is open up a PowerShell window as the farm account and run the Add-SPShellAdmin account with your credentials. To open PowerShell as a different user, right click on the SharePoint 2013 Management Shell (PowerShell with Windows.SharePoint.PowerShell already loaded) shortcut, Shift+right click on the SharePoint 2013 Management Shell in the context menu, and choose Run as a different user:
That's it! Short and sweet.