Powershell: Get user memberof as a manageable array

Author admin acount on October 2, 2011 | Print | Bookmark
(script is not finsihed)

Sometimes you want to query a user for all groups it contains and loop through them
for some reason (this example is to remove all of them except primary group)
$icid = samUser

$groups = (Get-ADUser -Identity $icid -Server domain.top -Properties memberOf).memberOf : Get-ADGroup : Select Name

foreach ($group in $groups) {
  Remove-DistributionGroupMember -Identity $group.Name -Member $icid

Was this article helpful?

Yes No

Category: Scripting, PowerShell

Last updated on October 3, 2011 with 1908 views