Add users to AD Group by email address

Hi everyone,

I’m kind of a newbie in Powershell and was wondering if some of you could help me figure this out. In our organization we use AD Groups to enroll clients phones, when we receive a new request we have to check if this user is member of these groups and add it if he is not.

I wrote a script that gets every group the user needs to be in and prompts you with it’s user name to add it to the groups, it looks kind of like this :

“Group1”, “Group2”, “Group3” | Add-ADGroupMember -Members (Read-Host -Prompt “Enter User Name”)

Problem is most of the time we don’t have the user’s SAMName, just its email address. Is there any way to modify this script making it query us with the user’s email address instead ?

Thank you in advance for your time

submitted by /u/Mudmen72
[link] [comments]

Leave a Reply