Add a group to members of a group in PowerShell

fdubrez picture fdubrez · Sep 26, 2012 · Viewed 17.1k times · Source

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

Answer

CB. picture CB. · Sep 26, 2012

One way is using ActiveDirectory module:

Import-Module ActiveDirectory

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