Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. $discovery = get-mailbox -RecipientTypeDetails "sharedmailbox"
  2. $date = get-date -Format "MM-dd-yyyy"
  3. $path = "C:\temp\$date.csv"
  4. $mailfrom = "whatever@whatever.com"
  5. $mailto = "whatever@hatever.comm"
  6. $mailcc = "whatever@hwatever.com"
  7. $MailSubject = "$date Results"
  8. $MailBody = "Attached is the file with all the data that your hearts desire. Please do all the things."
  9. $MailSMTP = "mailserver.com"
  10. $MailSMTPPort = "25"
  11.  
  12. if($discovery.count -ge 1){
  13.  
  14. $discovery | export-csv -NoTypeInformation -Path $path
  15. Write-Host $count
  16. Send-MailMessage -from $mailfrom -to $mailto -cc $mailcc -Subject $MailSubject -Body $MailBody -SmtpServer $MailSMTP -Port $MailSMTPPort -Attachments $path
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement