用户登录
用户注册

分享至

PowerShell 自动给新员工发送欢迎邮件

  • 作者: 森么辣么萌
  • 来源: 51数据库
  • 2022-08-17
$today = Get-Date
$csvlocation = "d:\Welcome_Letter\newsletter.csv"
$pdflocation = "d:\Welcome_Letter\Reset Password for Global Mial Account.pdf"
$htmbody = (Get-Content d:\Welcome_Letter\1.html | Out-String)
Get-QADUser -searchroot 'contoso.com.cn/Staff/' -IncludedProperties PrimarySMTPAddress |  Where-Object {($_.whenCreated - $today).days -eq "1"} | select name, whenCreated, PrimarySMTPAddress | export-csv $csvlocation -notype -Encoding "UTF8"
import-csv $csvlocation |  ForEach-Object {Send-MailMessage -Subject "Welcome to Join Contoso - $((Get-Date).ToShortDateString())" -Body $htmbody -BodyAsHtml -Attachments $pdflocation -From "welcome@contoso.com" -To $_.PrimarySMTPAddress -Bcc "webmaster@contoso.com"-SmtpServer "Smtp.contoso.cn" -Encoding ([System.Text.Encoding]::UTF8) }
软件
前端设计
程序设计
Java相关