batch file - Error The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered -
i trying run powershell script windows batch file. sharepoint related script uses import-spdata
.
this works without issue when using usera
's login. however, if try run same batch file userb
's login, 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 not accessible. cmdlets featuredependencyid not registered.
import-spdata : cannot access local farm. verify local farm configured, available, , have appropriate permissions access database before trying again.
at c:\ps\run_mypsscript.ps1:5 char:18
userb
has permissions run bat
, ps1
files.
you assuming, error related permission either bat or powershell file.
the error comes sp cmdlet, have opened bat file , run powershell script. throws error. userb has not apropriate rights farm. hence error:
...and have appropriate permissions access database before trying again.
compare permissions usera , userb on farm , database.
or use sledgehammer , log usera run following powershell script:
$db = get-spdatabase | {$_.name -eq "sharepoint_configdb"} add-spshelladmin "domain\userb" -database $db
Comments
Post a Comment