How to Copy a Members Groups from 1 user to another, but skipping 1 or two that aren't needed RRS feed

  • Question

  • Hi

    I am fairly new to Powershell, and have this script  part of below

    Having gotten the .samAccount Name of SourceAcc & DestAcc, I am trying to merge Group Membership from Source to Desination, but need to skip one or maybe later 2 or 3 particular groups.

    The code I have at present for adding the members is 

              compare-object $DestMember.memberof $SourceMember.memberof | where-object {$_.sideindicator -eq '=>'} | 
                Select-Object -expand inputobject | foreach {add-adgroupmember "$_" $DestAcc}

    But need to for now skip over the Group XXX_U_vProfile and any like it, (so they are note copied across.

    But for some reason cannot get it to work correctly.

    Any Help Greatly Appreciated

    • Moved by Bill_Stewart Friday, July 27, 2018 8:42 PM Abandoned
    Tuesday, May 29, 2018 5:19 PM

All replies

  • Where-Object{ $_ -ne 'Group XXX_U_vProfile'}


    Tuesday, May 29, 2018 5:32 PM