Powershell: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered
Solution 1
Ok, I managed to get this to work.
According to Microsoft:
In order to use Windows PowerShell for SharePoint 2010 Products, a user must be a member of the SharePoint_Shell_Access role on the configuration database and a member of the WSS_ADMIN_WPG local group on the computer where SharePoint 2010 Products is installed.
http://technet.microsoft.com/en-us/library/ff607596%28v=office.14%29.aspx
To do this:
- Open the SharePoint management shell (run as administrator if you have User Account Control activated)
- Add
SharePoint_Shell_Access
role to USERB for the SharePoint configuration database.
Can use the following PowerShell code to do this:
$dbs = Get-SPDatabase; foreach($d in $dbs) {If($d.name.contains("SharePoint_Config")){Add-SPShellAdmin "domain\USERB" -database $d}}
- Make sure the SharePoint site collection and document library/list (if any) also have the proper permissions for
USERB
Solution 2
Sharepoint is a beast to deal with. I would supsect UserB doesnt the proper sharepoint permissions and/or access to the content database
I would compare the permission for UserA and UserB at the Windows, Sharepoint, and DB level to look for differences.
Related videos on Youtube
thilina R
Updated on September 18, 2022Comments
-
thilina R over 1 year
I am trying to run a PowerShell script from a windows batch file. This is a SharePoint related script that uses
Import-SPData
.This works without any issue when using
USERA
's login. However, if I try to run the same batch file fromUSERB
's login, I get the error below:c:\PS>ExecMyPowershellScript.bat c:\PS>C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile " C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\P OWERSHELL\Registration\psconsole.psc1" -command "c:\ps\MyPSScript.ps1" The local farm is not accessible. Cmdlets with FeatureDependencyId are not regis tered. Import-SPData : Cannot access the local farm. Verify that the local farm is pro perly configured, currently available, and that you have the appropriate permis sions to access the database before trying again. At C:\ps\Run_MyPSScript.ps1:5 char:18 ...
I made sure that
USERB
has permissions to thebat
and theps1
files.I am using
PowerShell
version 2 andSharePoint Server 2010