Move users from one AD group to another


hi,

i have power shell command copies users 1 group another

get-adgroupmember "group1" |  get-aduser | foreach-object {add-adgroupmember -identity "group2" -members $_}

how modify command move users , leave original group empty.

meaning don't want leave users in first group


dalibor bosic

there not reason pipe on get-aduser, can try like

get-adgroupmember "group1" | foreach-object {   add-adgroupmember -identity "group2" -members $_   remove-adgroupmember -identity "group1" -members $_ }


if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.

don't retire technet



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

CRL Revocation always failed

Failed to query the results of bpa xpath

0x300000d errors in Microsoft Remote Desktop client