GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Need help adding more groups to exclusion list

Home Forums Scripting PowerShell Need help adding more groups to exclusion list

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    joeyg2391
    Member
    #162154

    hello,
    i found and modified the script below and was wondering if i can add more groups that i want to exlude from copying from the source user to destination user. Can you assist? Also, what editor can i use to show me the output of each line as it’s executing?

    Thanks

    write-output “This script helps to add user to all the Groups which other user is memberof.It is can be normally used when new user needs to have all the group membership of the existing users”
    write-output ” ”
    write-output ” ”
    $SName = Read-Host “Please Enter the alias name of the source user ”
    $DName = Read-Host “Please Enter the alias name of the Destination user ”
    $EXName = Read-Host “Please Enter the name of the group you want to exclude ”
    $K = Get-QADUser $SName |Select-Object -ExpandProperty MemberOf | Get-ADGroup -Properties name | Where SamAccountName -ne $EXName | Select-Object SamAccountName
    foreach($user in $K.SamAccountName)
    {
    Add-QADGroupMember -Identity $user -Member $DName
    }[/CODE][CODE]
    write-output “This script helps to add user to all the Groups which other user is memberof.It is can be normally used when new user needs to have all the group membership of the existing users”
    write-output ” “
    write-output ” “
    $SName = Read-Host “Please Enter the alias name of the source user “
    $DName = Read-Host “Please Enter the alias name of the Destination user “
    $EXName = Read-Host “Please Enter the name of the group you want to exclude “
    $K = Get-QADUser $SName |Select-Object -ExpandProperty MemberOf | Get-ADGroup -Properties name | Where SamAccountName -ne $EXName | Select-Object SamAccountName
    foreach($user in $K.SamAccountName)
    {
    Add-QADGroupMember -Identity $user -Member $DName
    }[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.