如何在批处理文件中使用Exchange 2010 cmdlet

如何在批处理文件中使用Exchange 2010 cmdlet,cmd,exchange-server,cmdlets,Cmd,Exchange Server,Cmdlets,我可以直接在Exchange命令行管理程序中正确运行Get-ActiveSyncDeviceAccessRule。 (参考资料:) 然后我编写了一个批处理文件,如下所示,但我得到了CommandNotFoundException。我想知道如何将此cmdlet与cmd.exe一起使用?有人能帮我吗?多谢各位 (编者按:接下来的三行是为了格式化而换行的。原来是一行) 我在standardError.txt中得到错误,如下所示: The term 'Get-ActiveSyncDeviceAccess

我可以直接在Exchange命令行管理程序中正确运行Get-ActiveSyncDeviceAccessRule。 (参考资料:)

然后我编写了一个批处理文件,如下所示,但我得到了
CommandNotFoundException
。我想知道如何将此cmdlet与cmd.exe一起使用?有人能帮我吗?多谢各位

(编者按:接下来的三行是为了格式化而换行的。原来是一行)

我在
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
术语“Get-ActiveSyncDeviceAccessRule”未被识别为
cmdlet、函数、脚本文件或可操作程序。检查单词的拼写
名称,或者如果包含路径,请验证路径是否正确,然后重试。
第1行字符:31
+获取ActiveSyncDeviceAccessRule(由OP在问题编辑中回答。转换为社区Wiki答案。请参阅)

OP写道:

我已经解决了我的问题。我错过了一些连接Exchange服务器的命令。并且cmdlet
Get-ActiveSyncDeviceAccessRule
属于Exchange Server 2010 SP1。您可以在Exchange命令行管理程序的“属性”窗口中找到目标命令

我更新了我的批处理文件,如下所示。它是有效的

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
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