开发者

How do I run a Exchange 2007 PowerShell script from the command line?

开发者 https://www.devze.com 2023-03-08 19:57 出处:网络
I have a very basic PowerShell script called MyScript.ps1 that runs quite happily in the Exchange Management Shell:

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
0

精彩评论

暂无评论...
验证码 换一张
取 消