{"id":16791,"date":"2010-10-17T00:01:00","date_gmt":"2010-10-17T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/10\/17\/create-exact-copies-of-active-directory-security-groups-in-a-new-forest\/"},"modified":"2010-10-17T00:01:00","modified_gmt":"2010-10-17T00:01:00","slug":"create-exact-copies-of-active-directory-security-groups-in-a-new-forest","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/create-exact-copies-of-active-directory-security-groups-in-a-new-forest\/","title":{"rendered":"Create Exact Copies of Active Directory Security Groups in a New Forest"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: Arial\"><span style=\"color: #000000\"><strong><span><span style=\"font-size: 10pt\">Summary<\/span><\/span><\/strong><span><span style=\"font-size: 10pt\">: Guest Blogger Oliver Lipkau shows us how to create exact copies of Active Directory security groups in a new forest.<\/span><\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">Microsoft Scripting Guy Ed Wilson here. We have a guest blogger today: Oliver Lipkau. Here is Oliver&rsquo;s scripting biography. <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"color: #000000\"><span style=\"font-size: 10pt\">I have been scripting for more than 10 years. I started with batch at the age of 13 by modifying the school&rsquo;s computer. Today, my main scripting language is Windows PowerShell. It allows me to automate the majority of my routine management of servers and clients. My specializations are ADSI and WMI. I also code in vbs, ahk, html, js, batch, php, and asp. But Windows PowerShell is my favorite. My blog is <\/span><\/span><span style=\"font-size: 10pt\"><a href=\"http:\/\/oliver.lipkau.net\/blog\"><span style=\"color: #0000ff\">http:\/\/oliver.lipkau.net\/blog<\/span><\/a><\/span><span style=\"font-size: 10pt;color: #000000\">. <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family:;font-size:\"><span style=\"font-family: Calibri\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">Do you know the kinds of tasks that look simple but turn out to be much trickier than you thought? Recently I was confronted with such a task. I was asked to write a script that would create exact copies of Active Directory security groups in a new forest.<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">My first thought was that it would take me all of five minutes to finish the script. Because I had already written functions to query Active Directory for groups and users, as well as for manipulating group membership. <\/span><\/span><\/span><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">How wrong I was! As it turns out, adding a user to a domain local security group in a trusted forest is not as easy as I had thought.<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"color: #000000\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt\">The first step<\/span><\/span><\/span><span style=\"font-size: 10pt\"><span style=\"font-family:;font-size:\"><span style=\"font-family: Calibri\">&mdash;<\/span><\/span><span><span style=\"font-family: Arial\">finding all the groups I need to re-create<\/span><\/span><span style=\"font-family:;font-size:\"><span style=\"font-family: Calibri\">&mdash;<\/span><\/span><\/span><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt\">is easy. To do this I query Active Directory like this:<\/span><\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221; <\/p>\n<p><\/span><span style=\"color: #2b91af\">$root<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectoryEntry(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/RootDSE&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectorySearcher<\/span><span style=\"color: #808080\"> <\/p>\n<p><\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.filter<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;(&amp;(objectcategory=group)(|(sAMAccountName=$Name)(cn=$Name)(name=$Name)))&#8221; <\/p>\n<p><\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.FindAll()<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Foreach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.GetDirectoryEntry()}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">Because this is something I might use more than once, why not make a nice function that can be used again? Also, being able to choose the <strong>search<\/strong> root might be a good idea because I will be working in two different domains (and forests). With this in mind, I refactored the above code into this function:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;*&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$root<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectoryEntry(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/RootDSE&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectorySearcher<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(!(<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #000000\">))<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$root<\/span><span style=\"color: #000000\">.defaultNamingContext}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.SearchRoot<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;LDAP:\/\/$SearchRoot&#8221; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.filter<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;(&amp;(objectcategory=group)(|(sAMAccountName=$Name)(cn=$Name)(name=$Name)))&#8221; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.FindAll()<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Foreach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.GetDirectoryEntry()}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221;<\/span> <\/div>\n<\/blockquote>\n<div class=\"code\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1777.WES-10-17-10-01_4B9D4CC5.jpg\"><img decoding=\"async\" height=\"304\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6866.WES-10-17-10-01_thumb_28F90E4A.jpg\" alt=\"Image of output of function\" border=\"0\" title=\"Image of output of function\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/div>\n<div class=\"code\">&nbsp;<\/div>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">There we go! Now I need to create the equivalent group in the new forest. To do this I will use this function:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">Function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">New-Group<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$Name<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$ParentContainer<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[ValidateSet(<\/span><span style=\"color: #808080\">&#8220;Universal&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;Global&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;DomainLocal&#8221;<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$GroupScope<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Global&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[ValidateSet(<\/span><span style=\"color: #808080\">&#8220;Security&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;Distribution&#8221;<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Security&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">switch<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$GroupScope<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Global&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;DomainLocal&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">4<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Universal&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">8<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">modify<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">type<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">attribute<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">is<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">security<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">enabled<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8216;Security&#8217;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-bor<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">0x80000000}<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$Parent<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[adsi]<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/$ParentContainer&#8221; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$Parent<\/span><span style=\"color: #000000\">.Create(<\/span><span style=\"color: #808080\">&#8220;group&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;CN=$Name&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;sAMAccountname&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$Name<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;grouptype&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;description&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #000000\">)}<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.SetInfo()<\/span><span style=\"color: #808080\">&nbsp;&nbsp;&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">Combining this function with the <strong>Get-Group<\/strong>, I can easily create the new group:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221; <\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\"> &#8220;ou=MyTest,dc=om,dc=net&#8221; <\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #0000ff\">%<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">New-Group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.cn<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ParentContainer<\/span><span style=\"color: #808080\"> &#8220;ou=MyTest,dc=tww832,dc=omtest1,dc=net&#8221; <\/span><span style=\"color: #000000\">-GroupScope<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">DomainLocal<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Security<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Description<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.description}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">To make my life easier in the next steps, I will save this new group in a variable:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$newGroup<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221; <\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\"> &#8220;ou=MyTest,dc=tww832,dc=omtest1,dc=net&#8221;<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">The next step will be to enumerate all the members in the original group. The members of a group are listed in the <strong>member<\/strong> property of the <strong>LDAP<\/strong> object. Knowing this means that I can show the list of members with this line:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">(Get-Group<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221; <\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\"> &#8220;ou=MyTest,dc=om,dc=net&#8221;<\/span><span style=\"color: #000000\">).member<\/span> <\/div>\n<\/blockquote>\n<p><span><\/p>\n<p class=\"CodeBlock\"><span style=\"font-family: 'Lucida Sans Typewriter'\"><span style=\"font-size: 10pt;color: #000000\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7534.WES-10-17-10-02_605F1F78.jpg\"><img decoding=\"async\" height=\"302\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7140.WES-10-17-10-02_thumb_057C69E5.jpg\" alt=\"Image of showing list of members\" border=\"0\" title=\"Image of showing list of members\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/span><\/span><\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">The last thing I need to figure out is how to add the users in this list to the new group. Normally, the easiest way to add a user to a group is in this manner:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$user<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[adsi]<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/cn=Oliver,ou=MyTest,dc=om,dc=net&#8221; <br \/><\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$newgroup<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$Group<\/span><span style=\"color: #000000\">.add(<\/span><span style=\"color: #2b91af\">$user<\/span><span style=\"color: #000000\">.Path)<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">However, this will not work in this case because users from trusted domains are represented as <strong>ForeignSecurityPrincipals<\/strong> (FSPs). FSP objects only contain the user&rsquo;s SID and are converted to a <strong>user<\/strong> object in the domain where the object resides. Executing the code above returns this error message:<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6471.WES-10-17-10-03_4AB4C10E.jpg\"><img decoding=\"async\" height=\"302\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5383.WES-10-17-10-03_thumb_20851326.jpg\" alt=\"Image of error message\" border=\"0\" title=\"Image of error message\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/span><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">One way to work around this problem is to add the users to the new group by their SID. To do this I will first have to get the object&#8217;s SID. I do this by using another function:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-ObjectSID<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[adsi]<\/span><span style=\"color: #2b91af\">$object<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$objectSid<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[byte[]]<\/span><span style=\"color: #2b91af\">$Object<\/span><span style=\"color: #000000\">.objectSid.value<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$sid<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">new-object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.Security.Principal.SecurityIdentifier<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$objectSid<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$sid<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">When I have the SID, I can add the object to the new group. I must be careful because the syntax is slightly different when referencing the object by its SID:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #2b91af\">$Group<\/span><span style=\"color: #000000\">.add(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/&lt;SID=$SID&gt;&#8221;<\/span><span style=\"color: #000000\">)<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">So the line in the script to add the users looks like this:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">(Get-Group<\/span><span style=\"color: #808080\"> &#8220;Test_Group&#8221; <\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\"> &#8220;ou=MyTest,dc=om,dc=net&#8221;<\/span><span style=\"color: #000000\">).member<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Foreach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$SID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-ObjectSID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([adsi]<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/$_&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #2b91af\">$newGroup<\/span><span style=\"color: #000000\">.add(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/&lt;SID=$SID&gt;&#8221;<\/span><span style=\"color: #000000\">)}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">After running the script, we can take a look at both groups and see that both have the same members.<\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"color: #000000\"><span style=\"font-family:;font-size:\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4426.WES-10-17-10-04_78063111.jpg\"><img decoding=\"async\" height=\"302\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3733.WES-10-17-10-04_thumb_2AF5C179.jpg\" alt=\"Image of groups having same members\" border=\"0\" title=\"Image of groups having same members\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/span><\/span><\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"color: #000000\"><span style=\"font-family:;font-size:\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3240.WES-10-17-10-05_39DCF093.jpg\"><img decoding=\"async\" height=\"565\" width=\"504\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5482.WES-10-17-10-05_thumb_2D029A75.jpg\" alt=\"Image of groups having same members\" border=\"0\" title=\"Image of groups having same members\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/span><\/span><\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span style=\"color: #000000\"><span style=\"font-family:;font-size:\"><span><span style=\"font-family: Symbol\"><span style=\"font-size: 10pt\"><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8032.WES-10-17-10-06_0417856C.jpg\"><img decoding=\"async\" height=\"562\" width=\"504\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8228.WES-10-17-10-06_thumb_4D5A2A67.jpg\" alt=\"Image of groups having same members\" border=\"0\" title=\"Image of groups having same members\" style=\"border-bottom: 0px;border-left: 0px;margin:;padding-left: 0px;padding-right: 0px;border-top: 0px;border-right: 0px;padding-top: 0px\" \/><\/a><\/span><\/span><\/span><\/span><\/span><\/p>\n<p class=\"Num-Caption\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"font-family: Arial\"><span style=\"font-size: 10pt;color: #000000\">The only thing left to do is to pull together all of these steps and allow the script to process multiple groups at once. This is shown here:<\/span><\/span><\/span><\/p>\n<blockquote>\n<div class=\"code\"><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;*&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$root<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectoryEntry(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/RootDSE&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.DirectoryServices.DirectorySearcher<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(!(<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #000000\">))<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$SearchRoot<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$root<\/span><span style=\"color: #000000\">.defaultNamingContext}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.SearchRoot<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;LDAP:\/\/$SearchRoot&#8221; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.filter<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;(&amp;(objectcategory=group)(|(sAMAccountName=$Name)(cn=$Name)(name=$Name)))&#8221; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$searcher<\/span><span style=\"color: #000000\">.FindAll()<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Foreach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.GetDirectoryEntry()}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <\/p>\n<p><\/span><span style=\"color: #000000\">Function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">New-Group<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$Name<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$ParentContainer<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[ValidateSet(<\/span><span style=\"color: #808080\">&#8220;Universal&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;Global&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;DomainLocal&#8221;<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$GroupScope<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Global&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[ValidateSet(<\/span><span style=\"color: #808080\">&#8220;Security&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;Distribution&#8221;<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;Security&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[string]<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\">&nbsp; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">switch<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$GroupScope<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Global&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">2<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;DomainLocal&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">4<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;Universal&#8221; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #800000\">8<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">#<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">modify<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">type<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">attribute<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">the<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">is<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">security<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">enabled<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8216;Security&#8217;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-bor<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">0x80000000}<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$Parent<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[adsi]<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/$ParentContainer&#8221; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$Parent<\/span><span style=\"color: #000000\">.Create(<\/span><span style=\"color: #808080\">&#8220;group&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #808080\">&#8220;CN=$Name&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;sAMAccountname&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$Name<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;grouptype&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$GroupTypeAttr<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.put(<\/span><span style=\"color: #808080\">&#8220;description&#8221;<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #2b91af\">$Description<\/span><span style=\"color: #000000\">)}<\/span><span style=\"color: #808080\">&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.SetInfo()<\/span><span style=\"color: #808080\">&nbsp;&nbsp;&nbsp; <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <\/p>\n<p><\/span><span style=\"color: #000000\">function<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-ObjectSID<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">param(<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[Parameter(mandatory<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #2b91af\">$true<\/span><span style=\"color: #000000\">)]<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">[adsi]<\/span><span style=\"color: #2b91af\">$object<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$objectSid<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">[byte[]]<\/span><span style=\"color: #2b91af\">$Object<\/span><span style=\"color: #000000\">.objectSid.value<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$sid<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">new-object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">System.Security.Principal.SecurityIdentifier<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$objectSid<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #800000\">0<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$sid<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <\/p>\n<p><\/span><span style=\"color: #2b91af\">$sourceOU<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;ou=groups,dc=olddomain,dc=oldforest,dc=com&#8221; <br \/><\/span><span style=\"color: #2b91af\">$destinationOU<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\"> &#8220;ou=groups,dc=newdomain,dc=newforest,dc=com&#8221; <\/p>\n<p><\/span><span style=\"color: #0000ff\">foreach<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$sourceOU<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; &#8220;Processing: `t&#8221; <\/span><span style=\"color: #000000\">+<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.cn<\/span><span style=\"color: #808080\">&nbsp;<br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">New-Group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.cn<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-ParentContainer<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$destinationOU<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">`<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">-GroupScope<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">DomainLocal<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-GroupType<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Security<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Description<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.description<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$newGroup<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-Group<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.cn<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-SearchRoot<\/span><span style=\"color: #808080\"> &#8220;ou=groups,dc=newdomain,dc=newforest,dc=com&#8221; <\/p>\n<p>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #0000ff\">foreach<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$member<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">in<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$group<\/span><span style=\"color: #000000\">.member)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$SID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Get-ObjectSID<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">([adsi]<\/span><span style=\"color: #808080\"><a href=\"\/\/$member\">LDAP:\/\/$member<\/a><\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #2b91af\">$newGroup<\/span><span style=\"color: #000000\">.add(<\/span><span style=\"color: #808080\">&#8220;LDAP:\/\/&lt;SID=$SID&gt;&#8221;<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #808080\"> <br \/>&nbsp;&nbsp;&nbsp; <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/div>\n<\/blockquote>\n<p class=\"MsoNormal\"><span style=\"font-family:;font-size:\"><span style=\"font-family: Calibri\"><span style=\"font-size: 10pt;color: #000000\"><em>&nbsp;<\/em>That is all for today. Many thanks to Oliver for sharing his script and knowledge. I hope you enjoyed it as much as I did. Tomorrow we will start a week of Splatting with James Brundage. <\/span><\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span><span style=\"color: #000000\"><span style=\"font-size: 10pt;font-family: Arial\">We invite you to follow us on <\/span><\/span><span style=\"font-size: 10pt\"><a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingguystwitter\"><span style=\"font-family: Arial;color: #0000ff\">Twitter<\/span><\/a><span style=\"font-family: Arial;color: #000000\"> and <\/span><a href=\"http:\/\/bit.ly\/scriptingguysfacebook\"><span style=\"font-family: Arial;color: #0000ff\">Facebook<\/span><\/a><span style=\"font-family: Arial;color: #000000\">. If you have any questions, send email to us at <\/span><a target=\"_blank\" href=\"mailto:scripter@microsoft.com\"><span style=\"font-family: Arial;color: #0000ff\">scripter@microsoft.com<\/span><\/a><span style=\"font-family: Arial;color: #000000\">, or post your questions on the <\/span><a target=\"_blank\" href=\"http:\/\/bit.ly\/scriptingforum\"><span style=\"font-family: Arial;color: #0000ff\">Official Scripting Guys Forum<\/span><\/a><\/span><span style=\"font-size: 10pt;font-family: Arial;color: #000000\">. See you tomorrow. Until then, peace.<\/span><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family:;font-size:\"><span style=\"font-family: 'Segoe UI'\"><span style=\"font-size: 10pt;color: #000000\">&nbsp;<\/span><\/span><\/span><\/p>\n<p><strong><span style=\"font-family:;font-size:\"><span style=\"font-family: 'Segoe UI'\"><span style=\"font-size: 10pt;color: #000000\">Ed Wilson and Craig Liebendorfer, Scripting Guys<\/span><\/span><\/span><\/strong><\/p>\n<p><span style=\"font-family:;font-size:\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Summary: Guest Blogger Oliver Lipkau shows us how to create exact copies of Active Directory security groups in a new forest. &nbsp; Microsoft Scripting Guy Ed Wilson here. We have a guest blogger today: Oliver Lipkau. Here is Oliver&rsquo;s scripting biography. I have been scripting for more than 10 years. I started with batch [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[7,56,190,3,20,61,45],"class_list":["post-16791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory","tag-guest-blogger","tag-oliver-lipkau","tag-scripting-guy","tag-user-accounts","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Summary: Guest Blogger Oliver Lipkau shows us how to create exact copies of Active Directory security groups in a new forest. &nbsp; Microsoft Scripting Guy Ed Wilson here. We have a guest blogger today: Oliver Lipkau. Here is Oliver&rsquo;s scripting biography. I have been scripting for more than 10 years. I started with batch [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=16791"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/16791\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=16791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=16791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=16791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}