MilesLogan
asked on
Script to add users to an AD group - export file with confirmation of what accounts where added.
Hi EE
I want to use the script below to set a task to add users to a group every night . The Users.txt file will be updated
by the application owner .
can someone help me modify it so the script outputs a file of the SamAccountNames that where added ?
something like export-csv C:\PS\AddedtoXXXgroup_$((G et-Date -Format MM-dd-yyyy)).csv -NoTypeInformation
Foreach ($User in GC \\Server\Share\Users.txt){
GC C:\PS\groups.txt | % {
Add-ADGroupmember -identity $_ -member $User
}
}
I want to use the script below to set a task to add users to a group every night . The Users.txt file will be updated
by the application owner .
can someone help me modify it so the script outputs a file of the SamAccountNames that where added ?
something like export-csv C:\PS\AddedtoXXXgroup_$((G
Foreach ($User in GC \\Server\Share\Users.txt){
GC C:\PS\groups.txt | % {
Add-ADGroupmember -identity $_ -member $User
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome!
ASKER