This project is read-only.

Running external powershell scripts

Topics: Developer Forum, User Forum
Mar 26, 2013 at 6:34 PM
Hi, is it possible to run external powershell scripts and return the result? (I'm asking because I can't get Add-PsSnapin "Microsoft.Exchange.Management.PowerShell.E2010" to work)

So, I've got this powershell monitor configured;
$Data="e:\scripts\whitespace.ps1"
$Counters.Add("Counter 1", $Data)
$Status.StatusID=1


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


I know whitepspace.ps1 runs ok from a regular powershell command prompt, and $Data returns the correct value.

However, the PolyMon monitor errors 'the item "e:\scripts\whitespace.ps1" is not recognized as the name of a cmdlet, function, script or operable program......

Any ideas?

Thanks, J