I have a very basic PowerShell script called MyScript.ps1 that runs quite happily in the Exchange Management Shell:
Get-MailboxDatabase -Status | where { $_.Mounted -eq $True }
If I try to run powershell开发者_如何学JAVA.exe MyScript.ps1
it complains because it can't find the Get-MailboxDatabase cmdlet. I'm guessing PowerShell and the Exchange Management Shell are running slightly differently?
How do I run an Exchange-based PowerShell script from the command line?
You need to load the Exchange management snapin before you can run Exchange scripts from the command line. I believe the code would be like so:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
精彩评论