2

Get-ActiveSyncDeviceAccessRule を Exchange 管理シェルで直接正しく実行できます。(参照: http://technet.microsoft.com/en-us/library/dd776124.aspx )

次に、以下のようにバッチファイルを書きましたが、CommandNotFoundException. このコマンドレットを cmd.exe で使用する方法を教えてください。誰でも私を助けることができますか?ありがとうございました。

(編集者注: 書式設定のために次の 3 行が折り返されています。本来は 1 行です)

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  Get-ActiveSyncDeviceAccessRule >C:\ActiveSyncDeviceAccessRule_output.txt
  2>C:\standardError.txt
echo %errorlevel% >C:\exitCode.txt

そして、次のようにエラーが発生しstandardError.txtます。

The term 'Get-ActiveSyncDeviceAccessRule' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:31
+ Get-ActiveSyncDeviceAccessRule <<<< 
    + CategoryInfo          : ObjectNotFound: (Get-ActiveSyncDeviceAccessRule: 
   String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
4

1 に答える 1

1

(質問編集でOPが回答。コミュニティWiki回答に変換。回答がない質問を参照してください。ただし、コメントで問題が解決しました(またはチャットで拡張されました)

OP は次のように書いています。

問題を解決しました。Exchange サーバーに接続するためのコマンドがいくつかありませんでした。また、コマンドレットGet-ActiveSyncDeviceAccessRuleは Exchange Server 2010 SP1 に属しています。対象のコマンドは、Exchange 管理シェルのプロパティ ウィンドウで見つけることができます。

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 
'C:\Program    Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1';
Connect-ExchangeServer -auto"

以下のようにバッチファイルを更新しました。そして、それは機能します。

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 
'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; 
Connect-ExchangeServer -auto;Get-ActiveSyncDeviceAccessRule" 
>C:\ActiveSyncDeviceAccessRule_output.txt 2>C:\standardError.txt
echo %errorlevel% >C:\exitCode.txt
于 2015-01-29T12:09:49.937 に答える