NOTE: this post corrects the incorrect advice given out by Microsoft – read this before you try using any MS blogs to fix this issue.
I’m sure we’ve all come across this error once in a while when launching SharePoint 2010 Management Shell – mostly because (as security-conscious devs and admins) we’ve got UAC on and have not chosen to run the shell as an administrator. Then there’s the other reason, which is the lack of SharePoint_Shell_Access role assignment in SQL Server for the logged in user. These are both extensively documented on the internet, in places such as Bradley Schacht’s blog.
However, there is now a NEW cause of this error!
The cause is documented on this MS blog and is correct. However, the solution provided doesn’t work. When you put in the “-version 2” it should come before the -NoExit switch. i.e. the ‘Target’ property of the shortcut should read:
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "
If you try and use the Microsoft recommended solution you get an error saying “Ampersand not allowed. The & operator is reserved for future use;”. If you remove the ampersand you get the error “The term ‘-Version’ is not recognized as the name of a cmdlet[… etc.]”
I hope this post saves people a bit of time.
Do you happen to know of a similar fix for sharepoint 2013 management shell? It would be a great help to me.
Not sure if you got this working – if you’re sure you’re running the shell as an administrator, and you’re sure you’re a member of SharePoint_Shell_Access role for the admin DB then I’m not sure what else you could check for SharePoint 2013. If you found a solution please share it!