Kez
Kez

Reputation: 268

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

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.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?

Upvotes: 2

Views: 6135

Answers (1)

IAmTimCorey
IAmTimCorey

Reputation: 16755

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

Upvotes: 3

Related Questions