Forum Discussion
captaindanger27
Sep 01, 2021Copper Contributor
Send email if iSCSI disk is not ONLINE
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
- farismalaebSteel Contributor
$X=$X=(Get-Disk | Where-Object -FilterScript {$_.BusType -Eq "iSCSI"} ).OperationalStatus IF ($X -NOTLIKE "Online"){ Send-MailMessage -From Alert@domain.com -To Admin@domain.com -Subject "HolyMoly The Disk is offline" -SmtpServer mysmtpserver.domain.com -Body "Here is the Message Body" } Please Click on Best Response if this answer helped.