cwstad2
asked on
powershell alert when ping time drops
Hi guys, we have a switching mechanism on our servers whereby the networks switch speeds varying on location. These times can vary but is it possible to email when the ping time drops, which would indicate the network switch. I have the following script below but doesnt seem to work correctly. also is it possible to loop until the condition is met
thanks
$ping = ping server
if ($ping -gt 1000)
{
Send-MailMessage -To user@company.com -From "user@company.com" -SmtpServer smtp.domain.com -Subject "Ready"
}
thanks
$ping = ping server
if ($ping -gt 1000)
{
Send-MailMessage -To user@company.com -From "user@company.com" -SmtpServer smtp.domain.com -Subject "Ready"
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
'f course it is, but you didn't say that yet ;-)
while (!($Ping = Test-Connection -Count 1 -TTL 2000 -EA SilentlyContinue Server)
-or $Ping.ResponseTime -gt 100)
{
Start-Sleep -seconds 60
}
Send-MailMessage -To user@company.com -From "user@company.com" -SmtpServer smtp.domain.com -Subject "Ready"
This will scan once every minute, until ping time is less or equal 100.
ASKER
thats great much appreciated
ASKER
thanks