单一的PowerShell命令我试图运行运行与管
powershell.exe -command "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest"
但由于某些原因,该命令挂起(大概管道被不同的解释)。有什么办法可以将它作为管道而不是逻辑或?
单一的PowerShell命令我试图运行运行与管
powershell.exe -command "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest"
但由于某些原因,该命令挂起(大概管道被不同的解释)。有什么办法可以将它作为管道而不是逻辑或?
的-command
参数用一个脚本块,eiter在这样的字符串定义它:
powershell.exe -command "& {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest}"
或者只是使用一个脚本块摆在首位:
powershell.exe -command {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn; Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest }
的最好办法,虽然是把它放在脚本文件中并使用-file参数。如果你使用这个计划任务(只是一个猜测),我建议你做后者。
当您仅在PowerShell会话中尝试时会发生什么?将认为这个问题是与'Add-PSSnapin' – Matt 2014-10-27 19:56:40