다음을 통해 공유


Sometimes when you upgrade, you also have to downgrade

Ran into an interesting logic puzzle today where upgrading to .Net 4 made SharePoint PowerShell angry. Had to chase my tail a little bit since the lab system I was troubleshooting had some other interesting configuration challenges with a single account which was both the install and database access account, but the real problem statement would have been something like this:

"When I launch the SharePoint Management Shell, I get the unhelpful error message which says:  "The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered" :

I *thought* I was looking at an issue with account permissions and the SharePoint_Shell_Access role, and I was, but not for this error. I also noticed that the window didn't say anything about SharePoint, just Powershell. And apparently I haven't been the only one confused by this:

https://jshidell.com/2012/12/20/fixing-the-local-farm-is-not-accessible-cmdlets-with-featuredependencyid-are-not-registered-when-trying-to-run-sharepoint-2010-powershell/

 So what's the deal? Here's the short answer: You need the magic of "-v 2" in your powershell shortcut, like this:

C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -v 2 -NoExit  " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

relaunch and all is good. No need to uninstall .Net 4.0 as some blogs have suggested.