Exchange powershell

Topics: Developer Forum, User Forum
Mar 22, 2013 at 4:38 PM
Edited Mar 22, 2013 at 4:49 PM
Hi, I'm trying to graph Exchange 2010 database white-space availability using script;

Add-PsSnapin "Microsoft.Exchange.Management.PowerShell.E2010" -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$server=Get-MailboxDatabase -identity db01 -Status | select Identity,@{Label="AvailableNewMailboxSpace";Expression={$_.AvailableNewMailboxSpace.ToMB()}} foreach ($_.Identity in $server) {
$Data=$_.AvailableNewMailboxSpace
$Counters.Add("Counter 1", $Data)
}
$Status.StatusID=1


But when it runs I get error;
Cannot invoke this function because the current host does not implement it.

I know the powershell runs from the powershell console.

Any ideas what is causing this error?

Thanks
Mar 22, 2013 at 5:20 PM

I’m don’t have experience with Exchange, but it looks to me like both your local PC and the Polymon are going to have to have the “Exchange 2010 Management Tools” installed on them.

http://technet.microsoft.com/en-us/library/bb232090(v=exchg.141).aspx

bob

From: jaydye [email removed]
Sent: Friday, March 22, 2013 11:39 AM
To: Bob Neumann
Subject: Exchange powershell [polymon:437651]

From: jaydye

Hi, I'm trying to graph database white-space availability using script;

Add-PsSnapin "Microsoft.Exchange.Management.PowerShell.E2010" -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$server=Get-MailboxDatabase -identity db01 -Status | select Identity,@{Label="AvailableNewMailboxSpace";Expression={$_.AvailableNewMailboxSpace.ToMB()}} foreach ($_.Identity in $server) {
$Data=$_.AvailableNewMailboxSpace
$Counters.Add("Counter 1", $Data)
}
$Status.StatusID=1


But when it runs I get error;
Cannot invoke this function because the current host does not implement it.

Any ideas what is causing this error?

Thanks

This message was sent secure. This e-mail communication, including any attached files may contain material that is proprietary, privileged, confidential, or otherwise legally exempt from disclosure. This communication is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering this communication to the intended recipient, you are prohibited from retaining, using, disseminating, forwarding, printing or copying this communication. If you have received this communication in error, please immediately notify the sender via return e-mail or telephone. This email has been scanned and found to be virus free. If this message contains a virus please contact postmaster@piedmont.org
Mar 22, 2013 at 5:23 PM
Edited Mar 22, 2013 at 5:29 PM
Hi, the management tools are installed already on the Polymon server and the script still fails.

I know my Exchange management tools are working because I can run the same script on the Polymon server via the powershell command window and it works fine.

Kinda stuck now.
Mar 22, 2013 at 5:32 PM

I still suspect it’s related to “add-pssnapin”. I’ve never used that exact cmdlet with Polymon, while I use “import-module” all the time.

Perhaps you can accomplish the same thing using “import-module”?

See http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/16/learn-how-to-load-and-use-powershell-snap-ins.aspx for a little more info about the difference between the two approaches.

Bob

From: jaydye [email removed]
Sent: Friday, March 22, 2013 12:23 PM
To: Bob Neumann
Subject: Re: Exchange powershell [polymon:437651]

From: jaydye

Hi, the management tools are installed already on the Polymon server and the script still fails.

Thanks

This message was sent secure. This e-mail communication, including any attached files may contain material that is proprietary, privileged, confidential, or otherwise legally exempt from disclosure. This communication is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering this communication to the intended recipient, you are prohibited from retaining, using, disseminating, forwarding, printing or copying this communication. If you have received this communication in error, please immediately notify the sender via return e-mail or telephone. This email has been scanned and found to be virus free. If this message contains a virus please contact postmaster@piedmont.org
Mar 22, 2013 at 5:34 PM
Thanks Bob. I stripped my powershell down to just;

Add-PsSnapin "Microsoft.Exchange.Management.PowerShell.E2010" -ErrorAction SilentlyContinue -WarningAction SilentlyContinue

and it fails right there.

I'll take a look at the import-module, thanks.