Simple script to send an email if a directory or mapped drive doesnt exist. This uses SMTP authentication.
$password = ConvertTo-SecureString 'EnterPassword!' -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ('username', $password)
if (Test-Path -Path P:\) {
"Path exists!"
} else {
send-MailMessage -SmtpServer smtp.office365.com -port 587 -UseSSL -To youremail@organization.com -From senderaddress@organiszation.com -credential $credential -Subject "Your Subject" -Body "Body Contents" -BodyAsHtml -Priority high
}
No comments:
Post a Comment