Guest User

Untitled

a guest
Jul 22nd, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. $files=(Get-ChildItem "$HOMEscriptexpire").FullName
  2. $send=@{
  3. to = "administrator@corp.internal"
  4. from = "administrator@corp.internal"
  5. Subject = "US"
  6. Attachment = $files
  7. SmtpServer = "10.10.10.10"
  8. }
  9.  
  10. $French=@{
  11. to = "administrator@corp.internal"
  12. from = "administrator@corp.internal"
  13. Subject = "FR"
  14. Attachments = $files
  15. SmtpServer = "10.10.10.10"}
  16.  
  17. $AU=@{
  18. to = "administrator@corp.internal"
  19. from = "administrator@corp.internal"
  20. Subject = "AU"
  21. Attachments = $files
  22. SmtpServer = "10.10.10.10"}
  23.  
  24. Get-AdUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False -and PasswordLastSet -gt 0 } -Verbose -Properties DisplayName, PasswordLastSet, Mail, Office -SearchBase "OU=Test,OU=CORP,DC=corp,DC=internal" -Server "10.10.10.1" | Where-Object {
  25. $_.PasswordLastSet.AddDays(30).Date -eq ((Get-Date).AddDays(30).Date)
  26. } |ForEach-Object -Verbose {
  27.  
  28.  
  29. $bodyreset=
  30. @"
  31. I delete real message because it was to big and I don't have any issue to receive these mail
  32. "@
  33.  
  34. if ( $_.office -like "FR*")
  35. {
  36. Send-MailMessage -Body "$bodyreset" -BodyAsHtml @french
  37. }elseif($_.office -like "US*")
  38. {
  39. Send-MailMessage -Body "$bodyreset" -BodyAsHtml @send
  40. }
  41. else{
  42. Send-MailMessage -Body "$bodyreset" -BodyAsHtml @AU
  43. }
  44. }
Add Comment
Please, Sign In to add comment