无法在 Exchange 管理 Shell 中批量执行 PowerShell 脚本

发布于 2025-01-09 12:23:55 字数 1265 浏览 1 评论 0原文

我有一个为我想从批处理文件运行的用户启用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半枫 2025-01-16 12:23:55

您已经发出了“返回字符串”命令,如果您想执行 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 with RemoteExchange.ps1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文