如何提取广告用户电子邮件,然后将其传递给功能以使用Aduser电子邮件发送电子邮件



我想从安全组中获取所有用户并提取电子邮件。收到他们的电子邮件后,我想将电子邮件地址列表传递给函数(理想情况下是循环(,以将电子邮件发送给该安全组中的所有用户。任何帮助都将受到赞赏。

$users = Get-ADGroupMember -Identity 'IS-Test-GRP' -Recursive |
  Select-Object -Unique | Get-ADUser -Properties Mail | Select-Object Mail
Foreach($user in $users)
{
Send-MailMessage -From joetest@mail.com -To $user.mail -Subject 'Migrating 
File Share' -Body 'Hello All, 
I will be migrating the share folder <   > from app02 to app03. Once 
completed I will email all users the new file path location to access the 
share. If you will be needing help creating a new shortcut, please contact 
the help desk. Any issues or questions, please let me know.  -Thank you' - 
SmtpServer 'mail.server.com'
}

尝试...

$users = $(Get-ADGroupMember -Identity 'IS-Test-GRP' -Recursive | Select- 
Object -Unique | Get-ADUser -Properties Mail).Mail

我看到的唯一问题是$users将是对象的集合。当您枚举集合时,我看不到您指定的是/具有Mail

最新更新