Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get SharePoint PowerShell to use .NET 2

I'm having a couple of problems with PowerShell. First, the PS configuration installed by SharePoint 2010 keeps popping this message:

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

I've googled that, and given everybody and their second cousin Sharepoint_Shell_Access to the config DB, with no luck. So, I wanted to try some of the PS commands. In this case, however, I'm getting a different error:

Microsoft SharePoint is not supported with version 4.0.30319.17929 of the Microsoft .Net Runtime.

I get that SP can't use .NET 4.0 or 4.5, but I can't find any suggestions on how to get PS to use the "right" version of .NET. I've found some references for something called PowerGUI, and changing the psgui.exe.config, but I don't have that.

Does anybody have any suggestions on how to solve the .NET version problem?

like image 442
EoRaptor013 Avatar asked Oct 15 '12 22:10

EoRaptor013


People also ask

Does PowerShell work with SharePoint?

PowerShell (latest version) supports SharePoint Online only. For those using on-premises SharePoint, PnP-PowerShell (legacy version) works with SharePoint 2013, 2016, 2019 and SharePoint Online but is no longer being maintained.


2 Answers

When you install powershell v3, version 2 is still available in side by side mode. In order to use the SharePoint snapin, you must launch v2 like this:

powershell -v 2

Then you can load the snapin for SharePoint.

For reference, here is the output from invoking PowerShell v2 from Windows 8 cmd.exe:

C:\Windows\System32\WindowsPowerShell\v1.0>powershell.exe -version 2
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Windows\System32\WindowsPowerShell\v1.0> $psversiontable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.6387
BuildVersion                   6.1.7600.16385
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1


PS C:\Windows\System32\WindowsPowerShell\v1.0> [Environment]::Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      50727  6387
like image 128
x0n Avatar answered Sep 25 '22 03:09

x0n


One can add the command line switch -version 2 to the Start Menu item by right clicking it, selecting Properties, and editing the string in the Target field.

This fix also clears up the erroneous message

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

I was getting this message when launching SharePoint 2010 Management Shell.

like image 37
Ott Avatar answered Sep 25 '22 03:09

Ott