Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $files=(Get-ChildItem "$HOMEscriptexpire").FullName
- $send=@{
- to = "administrator@corp.internal"
- from = "administrator@corp.internal"
- Subject = "US"
- Attachment = $files
- SmtpServer = "10.10.10.10"
- }
- $French=@{
- to = "administrator@corp.internal"
- from = "administrator@corp.internal"
- Subject = "FR"
- Attachments = $files
- SmtpServer = "10.10.10.10"}
- $AU=@{
- to = "administrator@corp.internal"
- from = "administrator@corp.internal"
- Subject = "AU"
- Attachments = $files
- SmtpServer = "10.10.10.10"}
- 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 {
- $_.PasswordLastSet.AddDays(30).Date -eq ((Get-Date).AddDays(30).Date)
- } |ForEach-Object -Verbose {
- $bodyreset=
- @"
- I delete real message because it was to big and I don't have any issue to receive these mail
- "@
- if ( $_.office -like "FR*")
- {
- Send-MailMessage -Body "$bodyreset" -BodyAsHtml @french
- }elseif($_.office -like "US*")
- {
- Send-MailMessage -Body "$bodyreset" -BodyAsHtml @send
- }
- else{
- Send-MailMessage -Body "$bodyreset" -BodyAsHtml @AU
- }
- }
Add Comment
Please, Sign In to add comment