WindowsバッチファイルからPowerShellスクリプトを実行しようとしています。これは、を使用するSharePoint関連のスクリプトですImport-SPData
。
これは、USERA
のログインを使用するときに問題なく機能します。ただし、USERB
のログインから同じバッチファイルを実行しようとすると、次のエラーが発生します。
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
...
私はそれを確認しましたUSERB
へのアクセス許可を持っているbat
とps1
ファイルを。
私はPowerShell
バージョン2を使用していますSharePoint Server 2010
わかりました、私はこれを機能させることができました。
Microsoftによると:
Windows PowerShell for SharePoint 2010製品を使用するには、ユーザーは、構成データベースのSharePoint_Shell_Accessロールのメンバーであり、SharePoint2010製品がインストールされているコンピューターのWSS_ADMIN_WPGローカルグループのメンバーである必要があります。
http://technet.microsoft.com/en-us/library/ff607596%28v=office.14%29.aspx
これをする:
SharePoint_Shell_Access
SharePoint構成データベースのUSERBに役割を追加します。これを行うには、次のPowerShellコードを使用できます。
$dbs = Get-SPDatabase; foreach($d in $dbs) {If($d.name.contains("SharePoint_Config")){Add-SPShellAdmin "domain\USERB" -database $d}}
USERB
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加