<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How Can I Add All the Users from an Existing Active Directory Group to a New Group?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/26/how-can-i-add-all-the-users-from-an-existing-active-directory-group-to-a-new-group.aspx</link><description>Hey, Scripting Guy! How can I add all the users from an existing Active Directory group to a new group? -- TG 
 Hey, TG. So you have a group (we’ll call it Group A) and you want to create an exact replica of that group (we’ll call it Group B). If we</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: How Can I Add All the Users from an Existing Active Directory Group to a New Group?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/26/how-can-i-add-all-the-users-from-an-existing-active-directory-group-to-a-new-group.aspx#3531292</link><pubDate>Thu, 08 Nov 2012 11:28:36 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3531292</guid><dc:creator>Al</dc:creator><description>&lt;p&gt;This fails on line 6 for me -&lt;/p&gt;
&lt;p&gt;Windows Script Host&lt;/p&gt;
&lt;p&gt;---------------------------&lt;/p&gt;
&lt;p&gt;Script:	\\server\share\GroupCopy.vbs&lt;/p&gt;
&lt;p&gt;Line:	6&lt;/p&gt;
&lt;p&gt;Char:	1&lt;/p&gt;
&lt;p&gt;Error:	Unspecified error &lt;/p&gt;
&lt;p&gt;Code:	80004005&lt;/p&gt;
&lt;p&gt;Source: 	(null)&lt;/p&gt;
&lt;p&gt;---------------------------&lt;/p&gt;
&lt;p&gt;OK &amp;nbsp; &lt;/p&gt;
&lt;p&gt;---------------------------&lt;/p&gt;
&lt;p&gt;I know this is quite an old post - but any chance of an update? Trying to run this on a 2008 R2 DC.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3531292" width="1" height="1"&gt;</description></item><item><title>re: How Can I Add All the Users from an Existing Active Directory Group to a New Group?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/26/how-can-i-add-all-the-users-from-an-existing-active-directory-group-to-a-new-group.aspx#3479481</link><pubDate>Tue, 07 Feb 2012 20:36:57 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3479481</guid><dc:creator>JeremyEngelWork</dc:creator><description>&lt;p&gt;Here is a script I wrote to do this in PowerShell. Note: it doesn&amp;#39;t handle groups with more than 1500 members. I haven&amp;#39;t had to do such a transfer, so I never accounted for it.&lt;/p&gt;
&lt;p&gt;function Transfer-GroupMembership {&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Param([string]$SourceGroup,[string]$TargetGroup)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch = New-Object System.DirectoryServices.DirectorySearcher&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch.PageSize = 1000&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch.SearchScope = &amp;quot;Subtree&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch.Filter = &amp;quot;(&amp;amp;(objectClass=group)(cn=$SourceGroup))&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;if(!($result = $objADSearch.FindOne())) { Write-Host &amp;quot;ERROR: No such group [$SourceGroup] found.&amp;quot; -ForeGroundColor Red; return }&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$members = $result.Properties[&amp;quot;member&amp;quot;]&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$objADSearch.Filter = &amp;quot;(&amp;amp;(objectClass=group)(cn=$TargetGroup))&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;if(!($result = $objADSearch.FindOne())) { Write-Host &amp;quot;ERROR: No such group [$TargetGroup] found.&amp;quot; -ForeGroundColor Red; return }&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$group = $result.GetDirectoryEntry()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$group.member += $members&lt;/p&gt;
&lt;p&gt; &amp;nbsp;$group.CommitChanges()&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Write-Host &amp;quot;The $($members.Count) members from $SourceGroup were successfully added to $TargetGroup.&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;}&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3479481" width="1" height="1"&gt;</description></item><item><title>re: How Can I Add All the Users from an Existing Active Directory Group to a New Group?</title><link>http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/26/how-can-i-add-all-the-users-from-an-existing-active-directory-group-to-a-new-group.aspx#3479462</link><pubDate>Tue, 07 Feb 2012 19:43:43 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3479462</guid><dc:creator>Laura S.</dc:creator><description>&lt;p&gt;This works great if there are at least 2 users in the &amp;quot;Old&amp;quot; group. &amp;nbsp;If there are not, there are problems. &amp;nbsp;This is what I used to get around that issue:&lt;/p&gt;
&lt;p&gt;&amp;#39; oGroup1 = &amp;quot;Old&amp;quot; group, oGroup2 = &amp;quot;New&amp;quot; group&lt;/p&gt;
&lt;p&gt;cMembers = oGroup1.Member&lt;/p&gt;
&lt;p&gt;&amp;#39; If there are no members in the group, you will receive an error because no collection exists.&lt;/p&gt;
&lt;p&gt;If IsEmpty(cMembers) Then&lt;/p&gt;
&lt;p&gt;	WScript.Echo &amp;quot;Group &amp;quot; &amp;amp; oGroup1.Name &amp;amp; &amp;quot; is empty.&amp;quot;&lt;/p&gt;
&lt;p&gt;&amp;#39; If there is only one member, it will be a string instead of a collection&lt;/p&gt;
&lt;p&gt;ElseIf TypeName(cMembers) = &amp;quot;String&amp;quot; Then&lt;/p&gt;
&lt;p&gt;	oGroup2.Add &amp;quot;LDAP://&amp;quot; &amp;amp; oGroup1.Member&lt;/p&gt;
&lt;p&gt;Else &lt;/p&gt;
&lt;p&gt;	For Each oUser In oGroup1.Member&lt;/p&gt;
&lt;p&gt; 		oGroup2.Add &amp;quot;LDAP://&amp;quot; &amp;amp; oUser&lt;/p&gt;
&lt;p&gt;	Next&lt;/p&gt;
&lt;p&gt;End If&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3479462" width="1" height="1"&gt;</description></item></channel></rss>