简体   繁体   中英

How do I pull the list of users and their email addresses and export to a file?

I started with what I have below.

$user = Get-ADGroupMember -Identity mygroup

foreach ($n in $user) {
    (Get-ADUser $n -Properties mail).mail
} 

Here is what worked and gave me what I wanted

$user = Get-ADGroupMember -Identity mygroup

foreach ($n in $user) {
    (Get-ADUser $n -Properties mail).mail | Add-Content c:\mygroup.txt
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM