Home
Adding users to an AD group using Powershell
Published: Thursday, 18 July 2019 | Categories: Powershell | Keywords: AD | Status: Posted | Created: Thursday, 18 July 2019 | Author: paul

Adding users to an Active Directory group from an Active Directory OU using Powershell.

# Add users from an AD OU into an AD Group with email domain
Get-ADUser -SearchBase ‘OU=Users,DC=contoso,DC=local’ -Filter 'mail -like "*@contoso.com"' | ForEach-Object {Add-ADGroupMember -Identity ‘AD Group Name’ -Members $_ }

# List number of users in AD OU with email domain
Get-ADUser -SearchBase ‘OU=Users,DC=contoso,DC=local’ -Filter 'mail -like "*@contoso.com"' | measure-object

# List number of user in AD Group
Get-ADGroupMember "AD Group Name" | measure-object

 


Add Comment
No Comments.