I have this script running every half hour. It sends an email if the value is greater than 99, but I don't want it to send an email every 30 min if value is still 99.
I would only like it to send an email once. if the value goes back less than 99 then again greater than 99 then send an email once only.
Here is the script
$main = 100
IF ($main -gt 99) {
Write-Host $main
##Send Email
}
else
{
Write-Host "Not Greater than 99."
}
What I tried, it doesn't work.
I tried using a global variable and setting equal nothing if $var1 -eq "NOTSENT" -and $main -gt 99 it will send email and set $var1 = "SENT". I need help here.
$main = 100
$var1
IF (($main -gt 99) -and ($var1 -eq "NOTSENT")) {
Write-Host $main
##Send Email
$var1 = "SENT"
}
else
{
Write-Host "Not Greater than 99."
$var1 = "NOTSENT"
}
Aucun commentaire:
Enregistrer un commentaire