Skip to content

Copy Active Directory Group Members Script

Copy Active Directory Group Membership Script

The following Script Copies members from one Active Directory Group to another Active Directory Group.

To start the Script run: .\CopyGroupMembership.ps1

You will be prompted to enter the Group whose membership you need to copy.

The you will be prompted to add the group name where you want to add the members.

At the end of the script you will get a small message saying that the members has been added to X group.

The Script is straight forward as you can see below.

#Created by : Shaun Hardneck
#Blog: www.thatlazyadmin.com

#Import the ActiveDirectory Module
Import-Module ActiveDirectory

Write-Host -ForegroundColor DarkYellow "Script will copy Group Membership to another Group"
$groupname = Read-Host -Prompt "'Enter the AD Group Name who's members needs to be copied'"

$member = Get-ADGroupMember -Identity $groupname

$copytogroup = Read-Host -Prompt 'Enter the AD Group Name that needs to be populated'

Add-ADGroupMember -Identity $copytogroup -Members $member


Write-Host -ForegroundColor Green "Members has been added to Group" $copytogroup

Sharing is caring!

Published inActive DirectoryPowerShellWindows Server 2012Windows Server 2016

Be First to Comment

Leave a Reply

Your email address will not be published.