I want to run some powershell commands on a SharePoint 2013 server. Unfortunately, I can't even seem to step up to the plate at all. Are the cmdlets not installed? I am running this powershell window as an admin. I am also logged in as a windows user in the local administrators group on this windows server. So, how do I get going on this?
1 Answer
If you're not using the SharePoint Management Shell (which needs to be run 'As Administrator') from the Start menu, you need to first issue:
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
The -EA 0
is typically unnecessary, it just continues without throwing an error if the snapin is already loaded.
SharePoint Server below SharePoint Subscription Edition uses a PowerShell Snapin, not Module.
The PnP cmdlets you attempted to install are for SharePoint Online, not SharePoint Server.
-
It's amazing the things that Microsoft's garbage docs don't contain in a basic getting started page. Thanks.– tnk479Commented Apr 22, 2022 at 15:39
-
Actually, it does allude to the need to run it, but, they say that you don't have to run it and they provide a path to the ps file that doesn't actually exist.– tnk479Commented Apr 22, 2022 at 15:41
-
With the SharePoint Management Shell, you do not have to register the snap-in that contains the cmdlets. Registration of the Microsoft.SharePoint.PowerShell.dll module for SharePoint Server cmdlets is automatic, as a result of the Add-PSSnapin Microsoft.SharePoint.PowerShell line in the SharePoint.ps1 file that is located in %CommonProgramFiles%\Microsoft Shared\Web Server Extensions<version>\Config\PowerShell\Registration, where version "15" equals SharePoint Server 2013, and version "16" equals SharePoint Server 2016. To use the PowerShell console, you must register this snap-in manually.– tnk479Commented Apr 22, 2022 at 15:41