Quantcast
Channel: THWACK: All Content - Server & Application Monitor
Viewing all articles
Browse latest Browse all 12281

PowerShell Question

$
0
0

We are new to SAM and want to create our own PowerShell Monitor.  I run the below script but get "Output Result: Get Output Failed".  

 

I used http://thwack.solarwinds.com/community/solarwinds-community/geek-speak_tht/blog/2012/10/08/the-basics-of-powershell-part-3, and http://www.solarwinds.com/NetPerfMon/SolarWinds/wwhelp/wwhimpl/js/html/wwhelp.htm#context=SolarWinds&file=OrionAPMPHComponentTypesWindowsPowerShell.htm for a reference but did not see an answer.  The script works from PowerShell on the server.

 

Code:

Add-PSSNapin -Name Microsoft.Exchange.Management.PowerShell.E2010;

$DateW = (Get-date).adddays(-1);

$DateC = (Get-date).adddays(-2);

$stat = 0;

$Backupsw = Get-MailboxDatabase -status | where {$_.Lastfullbackup -lt $DateW} | Where {$_.LastIncrementalBackup -lt $DateW};

$Backupsc = Get-MailboxDatabase -status | where {$_.Lastfullbackup -lt $Datec} | Where {$_.LastIncrementalBackup -lt $Datec};

If ($Backupsw -eq $null)

{

  Write-host "Message: Exchange backups are current";

  Exit 0;

}

if ($Backupsc -ne $null)

{

  Write-host "Message: The following Exchange backups are in a Critical State $Backupsc";

  Exit 3;

}

if ($Backupsw -ne $null)

{

  Write-host "Message: The following Exchange backups are in a Warning State $Backupsw";

  Exit 2;

}

 

 

Output:(replaced Exchange DB Names)

Output: ==============================================

Message: The following Exchange backups are in a Critical State ExchangeDB1 ExchangeDB2 ExchangeDB3


Viewing all articles
Browse latest Browse all 12281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>