Looping through 1 command with multiple arrays


Maybe I’m doing something wrong but I am using the the remove-unifiedgrouplinks command to remove some members of a group, but the command specifies that you need to have the -Identity and -Links parameters inputted, the problem is they are coming from 2 different list arrays(see my attempt at a script below.
For each user, the remove-unifiedgrouplinks command should go through all the groups and remove the user.

Can you help me out with this?

$User = Get-ADUser -Filter*

$GroupArray = Get-unifiedgroup

Foreach ($Item in $GroupArray)

{ Remove-UnifiedGroupLinks -Identity $Item.Alias -Linktype Members -Links $User -Confirm:$false }

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

Leave a Reply