單一的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