Powershell to check the public IP and trigger the mail


$IPstatus = Invoke-WebRequest -Uri "https://whatismyipaddress.com/ip/4.4.4.8" -Headers @{"Referer"="https://www.google.com/"; "User-Agent"="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"}
If ($IPstatus.StatusDescription -eq 'ok') {send-mailmessage -smtpserver smtp.office365.com -to pugazh@pugazh.co.in -from report@pugazh.co.in -subject 'MPLS Link is UP now' -Port 25}


Refer: Link

Comments

Popular posts from this blog

altiris software key

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe)

Troubleshooting Netlogon Error Codes