Copy Active Directory Group Members Script

0
4
views

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!

Previous articleCreate an Org-Wide Team in Microsoft Teams
About Me ? I Guess i would start by saying i am a family guys and full time SysAdmin and Tech Junky. This Blog is my first attempt to share information about daily issues i come across as a SysAdmin as well as some new deployments i am part of. Topics that i will cover will mostly be about Office 365,Windows,Exchange as well as Active Directory. I hope some of my Blog posts helps someone #LiveLongAndBeLazy #Exchange #Office 365 #ActiveDirectory #Hyper-V
SHARE

LEAVE A REPLY

Please enter your comment!
Please enter your name here