MS Exchange 2010:cmdlet 未作为计划任务正确执行

发布于 2024-11-17 23:17:07 字数 1186 浏览 3 评论 0原文

我已经使用计划任务和 New-MailboxExportRequest cmdlet 每晚将组织的邮箱导出到 .PST 存档文件有一段时间了。不幸的是,在存档操作完成后,ExportRequests 不会被删除,并且当 Exchange 确定它看到了足够的请求时,它会停止处理我的备份。

在 Exchange 命令行管理程序中运行时,以下命令非常适合清理请求:

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

但是,我没有成功地让这个 cmdlet 作为计划任务正确运行。

我使用以下语法:

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

当我手动执行任务时,它挂在“任务当前正在运行”处。 (0x41301)'直到我结束任务。请注意,我使用的帐户具有适当的权限级别,UAC 已禁用,并且在任务上启用了“以最高权限运行”。因此,我倾向于认为问题出在我的语法上。

非常感谢任何和所有的帮助。

编辑:

通过一个不相关的脚本问题找到了我的解决方案;正常使用时该 cmdlet 会要求确认。因此,我将脚本修改为以下内容:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange .ps1'; Connect-ExchangeServer -auto; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm:$false"

我的计划任务按预期运行并执行操作它的设计目的是。谢谢你的空间。

I've been using a Scheduled Task and the New-MailboxExportRequest cmdlet to export my organization's mailboxes to .PST archive files each night for awhile now. Unfortunately, the ExportRequests are not removed after the archive operation completes and when Exchange has decided it's seen enough Requests, it stops processing my backups.

The following works well for cleaning up the Requests when run at the Exchange Management Shell:

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

HOWEVER, I have not been successful in getting this cmdlet to run correctly as a Scheduled Task.

I am using the following syntax:

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

When I manually execute the Task, it hangs at 'The task is currently running. (0x41301)' until I end the task. Please note that I am using an account with the proper level of permissions, UAC is disabled, and 'Run with highest privileges' is enabled on the Task. I am therefore inclined to believe that the problem lies with my syntax.

Any and all help is HUGELY appreciated.

EDIT:

Found my solution via an unrelated scripting question; the cmdlet asks for confirmation in normal usage. Therefore, I modified my script to the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest -Confirm:$false"

My Scheduled Task runs as intended and does what it's designed to do. Thanks for the space.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

烟雨凡馨 2024-11-24 23:17:07

解决此问题的一般方法是将开关“-noninteractive”传递给 powershell.exe。这将确保 powershell 进程永远不会阻止用户输入任何命令。

请注意,这是在计划任务中运行 PowerShell 的一般建议,并与作者的修复结合使用。

请参阅“powershell /?”从命令提示符。

The general way to fix this issue is to pass the switch '-noninteractive' to the powershell.exe. This will ensure that the powershell process will never block on user input for any command.

Note that this is a general recommendation for running PowerShell in a scheduled task, and works in conjunction with the author's fix.

See 'powershell /?' from a command prompt.

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