Question

I would like to add a group to members of another group using PowerShell. I have seen a way to do that with vbscript but is it possible to do it with powershell?

My environment:
-Windows Server 2008 R2
-PowerShell 2.0

Was it helpful?

Solution

One way is using ActiveDirectory module:

Import-Module ActiveDirectory

Add-ADGroupMember -Identity <samaccountname of destination group> -Members <samaccountname of group to add in>

OTHER TIPS

This script copies the group members inside another specified group

$Source_Group = "CN=SourceGroupName,OU=Groups,DC=domain,DC=com"
$Destination_Group = "CN=DestinationGroupName,OU=Groups,DC=domain,DC=com"

$Target = Get-QADGroupMember $Source_Group
foreach ($Person in $Target) {
    add-QADGroupMember -identity $Destination_Group -member $Person.dn
}

Source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top