Sep 17 2012 2:24PM GMT
Posted by: Richard Siddaway
Active Directory, PowerShell
Change user attribute based on group membership
Posted by: Richard Siddaway
Want to change an attribute on all members of an Active Directory group. Then try this
Get-ADGroupMember -Identity Legal | where {$_.objectclass -eq "user"} | foreach { Set-ADUser -Identity $($_.distinguishedName) -Department "Student" }
Get the group members – filter out nested groups by checking the objectclass of the object. For each user set the attribute.
You can test its worked or look at an attribute in a similar way
Get-ADGroupMember -Identity Legal | where {$_.objectclass -eq "user"} | foreach { Get-ADUser -Identity $($_.distinguishedName) -Property Department | select Name, distinguishedName, Department }
You can perform a similar process with the Quest cmdlets




