Send email if iSCSI disk is not ONLINE

New Contributor

I would like to check if an iSCSI disk is online and if not then send an email.

The command we use to check the status is Get-Disk | Where-Object -FilterScript {$_.BusType -Eq "iSCSI"} 

The output shows OperationalStatus as Online when all is working well.

Could someone help me to create an if statement or some way to trigger an email notification if it's not Online.

Thank you.

1 Reply

@Shane Gillwald 

$X=$X=(Get-Disk | Where-Object -FilterScript {$_.BusType -Eq "iSCSI"} ).OperationalStatus
IF ($X -NOTLIKE "Online"){
Send-MailMessage -From -To -Subject "HolyMoly The Disk is offline" -SmtpServer -Body "Here is the Message Body"

Please Click on Best Response if this answer helped.