Written by Tamer Maher El-Sharkawy, Premier Field Engineer
When you launch a SharePoint 2010 Management Shell you might receive one or both of the following errors:
This could happen because the PowerShell version used by the shell isn’t the correct one.
At the command prompt run the following commands:
PS C:\ > $ver=$host | select version
PS C:\ > $ver.Version
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
If the version indicated is not “2”, the shell is indeed trying to execute with an unsupported runtime, and you get the error above.
First, try Import System Modules as shown:
If that does not resolve the issue, you can navigate to the Sharepoint Management Shell shortcut properties then add "-version 2" to the string in the Target field. Example:
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 ' "
Tamer Maher, MCP, MCTS, MCITP
Very good content.
I am trying to find the "Import System Modules" is that something that I should download / have?
The example shortcut above does not work. The -Version 2 needs to be before -NoExit.
Working shortcut is.
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 ' "
Thank you Kent. This syntax fixed my problem. I am still not sure why it broke all the sudden. I have been using sharePoint 2010 Management Shell several months without a problem. All of the sudden it stopped working. Wonder if it was due to updates. Anyway, all fixed.
Does NOT work for many processes that automatically use PowerShell like a scheduled task or PowerPivot with SSRS.
I am actually getting an error launching the SharePoint Management Shell for SP2013 on a Windows Server 2012.
select : The term 'Select-Object' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At C:\Program Files\Common Files\Microsoft Shared\Web Server
+ $ver = $host | select version
+ CategoryInfo : ObjectNotFound: (Select-Object:String) , Comma
+ FullyQualifiedErrorId : CommandNotFoundException
Thanks in advanced!
I tried this and the powershell starts then exits
Thanks a lot
@Lou - did you find a solution for Select issue ?
I fixed the 'select-object' problem in the following way. Hope it helps...
I found $env:psmodulepath as C:\Users\user_name\Documents\WindowsPowerShell\Modules;;C:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules;C:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules
As you can notice that AppFabric module path has repeated itself. I guess AppFabric has messed up with the psmodulepath while it got installed. So, I modified the PSModulePath variable under registry (at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment) to include
After this change, I am able to execute select & other basic cmdlets.