Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cleanup-reboot gist 3
### Un-comment lines below to allow of an emailed report ###
#Assign e-mail(s) to $sendto variable and SMTP server to $SMTPsrv
#$sendto = "first.last@domain.com#Can add additional emails separated by commas
#$from = "" #Set appropriate from address
#$SMTPsrv = "" #Set appropriate SMTP server
#$title = "Online servers with zero users"
#foreach ($email in $sendto) {
# $smtpTo = $email
# $smtpServer = $SMTPsrv
# $smtpFrom = $from
# $messageSubject = "Report: Online servers with zero users"
# $date = get-date -UFormat "%d.%m.%y - %H.%M.%S"
# $relayServer = (test-connection $smtpServer -count 1).IPV4Address.tostring()
# $message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
# $message.Subject = $messageSubject
# $message.IsBodyHTML = $true
# $message.Body = $finalout
# $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
# $smtp.Send($message)
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment