Copy members from multiple AD groups, how do I show which group members are copied from?
hi,
i need create @ script copy members multiple ad groups group.
the script works, want know in write-host here member copied from.
if use $source_group write test_a test_b on members.
can me ?
here test code:
$source_group = "test_a","test_b" $destination_group = "test_c" $target = $source_group | foreach { get-adgroupmember -identity $_ } foreach ($user in $target) { $username = $user.samaccountname add-adgroupmember -identity $destination_group -members $user.distinguishedname write-host “$username copied $??? $destination_group” }
$source_groups = "test_a", "test_b" $destination_group = "test_c" $source_groups | foreach-object { $group = $_ get-adgroupmember -identity $_ | foreach-object{ add-adgroupmember -identity $destination_group -members $_.distinguishedname write-host "$($_name) copied ($$group.name) $destination_group" } }
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment