如何在批处理文件中使用 Exchange 2010 cmdlet
我可以直接在 Exchange 命令行管理程序中正确运行 Get-ActiveSyncDeviceAccessRule。 (参考:http://technet.microsoft.com/en-us/library/ dd776124.aspx)
然后我编写了一个批处理文件,如下所示,但我得到了CommandNotFoundException
。我想知道如何将这个 cmdlet 与 cmd.exe 一起使用?有人可以帮助我吗?谢谢。
(编者注:接下来的三行被换行以进行格式化。最初是 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
I can run Get-ActiveSyncDeviceAccessRule correctly in Exchange Management Shell directly.
(reference: http://technet.microsoft.com/en-us/library/dd776124.aspx)
Then I wrote a batch file as below, but I got CommandNotFoundException
. I'd like to know how I can use this cmdlet with cmd.exe? Could anyone can help me? Thank you.
(Editor's note: The next three lines were wrapped for formatting. Originally 1 line)
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Get-ActiveSyncDeviceAccessRule >C:\ActiveSyncDeviceAccessRule_output.txt
2>C:\standardError.txt
echo %errorlevel% >C:\exitCode.txt
And I get error in standardError.txt
as below:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(OP 在问题编辑中回答。转换为社区 Wiki 答案。请参阅 没有答案的问题,但问题在评论中得到解决(或在聊天中扩展))
OP 写道:
(Answered by the OP in a question edit. Converted to a community Wiki Answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote: