I have an exchange monitor that uses powershell which is below. However I am getting a weird error which when I run on the Solarwinds server from a powershell command line works perfectly...
Code |
---|
$ErrorActionPreference = "silentlycontinue"; add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010; add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin; $Error.Clear(); $username = $args.get(0); if ( !$username ) { Write-Host "Message: Can't find "target_user" argument. Check documentation."; exit 1; } $stat = (Get-MailboxFolderStatistics -Identity $username -FolderScope Inbox | select itemsinfolder).itemsinfolder; if ($Error.Count -eq 0) { Write-Host "Message: Items in mailbox $username : $stat"; Write-Host "Statistic: $stat"; Exit 0; } Write-Host "Message: $($Error[0])"; Exit 1; |
The error I get is below:
Testing on node 'XX.XX.XX.XX' failed with 'Down' status ('Down' might be different if script exits with a different exit code).
The term 'Get-MailboxFolderStatistics' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Output: ==============================================
Message: The term 'Get-MailboxFolderStatistics' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Runnning in normal powershell command line i get the correct response:
e