无法在 Exchange 管理 Shell 中批量执行 PowerShell 脚本
我有一个为我想从批处理文件运行的用户启用 OWA 的脚本。从 Exchange 管理控制台来看,它运行良好。从批处理文件中打开 Echange 管理控制台也可以,但用于启用用户的脚本的执行将不会运行。
这是我的批处理文件:
PowerShell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1'"
这是结果:
Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Show quick reference guide: QuickRef
Tip of the day #50:
Bla bla bla
VERBOSE: Connecting to PROMAILVLZ-04.sfg.net.
VERBOSE: Connected to PROMAILVLZ-04.sfg.net.
C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1
[PS] C:\Script\Exchange\OWA_access>
“C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1”未执行,因为系统会提示您输入用户名,但情况并非如此。如果我在此(当前)“管理外壳”(C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1) 中运行该文件,它将正常运行。
有人吗?
提前致谢!
理查德
I have a script for enabling OWA for users that I want to run from a batch file. From the Exchange Management Console it runs fine. Opening the Echange management console from the batch file works as wel, but the execution of the script for enabling the user will not run.
Here's my batch file:
PowerShell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1'"
And this is the result:
Welcome to the Exchange Management Shell!
Full list of cmdlets: Get-Command
Only Exchange cmdlets: Get-ExCommand
Cmdlets that match a specific string: Help *<string>*
Get general help: Help
Get help for a cmdlet: Help <cmdlet name> or <cmdlet name> -?
Exchange team blog: Get-ExBlog
Show full output for a command: <command> | Format-List
Show quick reference guide: QuickRef
Tip of the day #50:
Bla bla bla
VERBOSE: Connecting to PROMAILVLZ-04.sfg.net.
VERBOSE: Connected to PROMAILVLZ-04.sfg.net.
C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1
[PS] C:\Script\Exchange\OWA_access>
"C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1" is not executed, as you will be prompted for a username, which is not the case. If I run the file in this (current) "management shell" (C:\Script\Exchange\OWA_access\enable_OWA_access_RM-versie.ps1), it will run without issues.
Anyone?
Thanks in advance!
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经发出了“返回字符串”命令,如果您想执行 ps1,您应该使用
&
或.
来代替,就像您对RemoteExchange 所做的那样。 ps1
。You have issued a "return string" command, should you want to execute a ps1, you should
&
or.
it instead, like you did withRemoteExchange.ps1
.