Powershell: Get user memberof as a manageable array
(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
}