<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>May I see your ID(entity)?</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/joec/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/joec/feed.xml</link>
    <description>The ramblings of an Identity geek...</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:45:50 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Active Directory Delegation via PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/joec/active-directory-delegation-via-powershell</link>
      <pubDate>Thu, 25 Apr 2013 12:17:01 GMT</pubDate>
      <dc:creator><![CDATA[Joe Corey]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/joec/2013/04/25/active-directory-delegation-via-powershell/</guid>
      <description><![CDATA[In Active Directory, we have plenty of ways to perform delegation on directory objects:


  The...]]></description>
      <content:encoded><![CDATA[<p>In Active Directory, we have plenty of ways to perform <a href="https://technet.microsoft.com/en-us/library/cc756087(v=WS.10).aspx">delegation</a> on directory objects:</p>

<ul>
  <li>The delegation wizard in ADU&amp;C</li>

  <li>The ACL Editor in ADU&amp;C</li>

  <li>Dsacls.exe command line</li>
</ul>

<p>However, each of these options are either manual in nature or don’t necessarily fit well into the object-oriented nature of something like PowerShell. Sure we can call dsacls from our script, but doesn’t allow for as much flexibility when it comes to working with the objects that get created from a command like Get-ADOrganizationalUnit or Get-ADGroup. I’m often asked the best way to programmatically grant permissions within the directory so I thought I’d illustrate how this can be accomplished with everyone’s favorite language, PowerShell!</p>

<p>I’ll be using some of the cmdlets from the Active Directory PowerShell module, so that means you’ll need to have at least one Server 2008 R2 domain controller on your network or a down-level domain controller with the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=2852">Active Directory Management Gateway Service</a> installed. At it’s core, I’m still relying on the same .NET libraries that have existed for a while in <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.aspx">System.DirectoryServices</a>. This just highlights the Active Directory versions of the Get-ACL and Set-ACL cmdlets and also show some ways that makes working with this class a little more user friendly without having to dive into C# and managed code. </p><p>The pseudo code for doing this is pretty simple:</p><ol><li>Get the current DACL on the object we desire to set permissions on (can be a leaf object, OU, container, or directory partition).</li><li>Append the existing DACL with a new <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">ActiveDirectoryAccessRule</a>.</li><li>Re-apply the DACL.</li></ol><p>The biggest hurdle is generally #2 when you have to create a <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">ActiveDirectoryAccessRule</a> object. Unfortunately, the constructor for this object takes schemaIDGUID and rightsGUID values to dictate what objects, attributes, and extended rights are being delegated. Below I’ll walk step-by-step through a sample script so you can see how to accomplish this task:</p><p>First I’ll get myself setup with references to some objects I’ll need later:</p><pre><span style="color: rgb(95, 158, 160);">Import-Module</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">ActiveDirectory</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(0, 128, 0);">#Bring up an Active Directory command prompt so we can use this later on in the script
</span><span style="color: rgb(0, 0, 255);">cd</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">ad</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(0, 128, 0);">#Get a reference to the RootDSE of the current domain
</span><span style="color: rgb(128, 0, 128);">$rootdse</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">Get-ADRootDSE</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(0, 128, 0);">#Get a reference to the current domain
</span><span style="color: rgb(128, 0, 128);">$domain</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">Get-ADDomain</span>
</pre><p>&nbsp;</p><p>Now, I want to create two hash tables to store the GUID values, but reference them by their display names. I don’t know about you, but I can never remember that 00299570-246d-11d0-a768-00aa006e0529 is the rightsGUID for allowing the forced changing of a user’s password. I can, however, remember “Reset Password” which is the displayName for this right. If you care to see the hash tables in the raw (or just need to find the display name reference"), simply type the variable names (e.g. <span style="color: rgb(128, 0, 128);">$guidmap).</span></p><pre><span style="color: rgb(0, 128, 0);">#Create a hashtable to store the GUID value of each schema class and attribute
</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">@</span><span style="color: rgb(0, 0, 0);">{}
</span><span style="color: rgb(95, 158, 160);">Get-ADObject</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-SearchBase</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 128);">$rootdse</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">SchemaNamingContext</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(95, 158, 160);">-LDAPFilter</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 0);">"(schemaidguid=*)"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Properties</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">lDAPDisplayName</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">schemaIDGUID</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">|</span><span style="color: rgb(0, 0, 0);"> 
</span><span style="color: rgb(255, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"> {</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 128);">$_</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">lDAPDisplayName</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(139, 69, 19);">System.GUID</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 128);">$_</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">schemaIDGUID</span><span style="color: rgb(0, 0, 0);">}

</span><span style="color: rgb(0, 128, 0);">#Create a hashtable to store the GUID value of each extended right in the forest
</span><span style="color: rgb(128, 0, 128);">$extendedrightsmap</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">@</span><span style="color: rgb(0, 0, 0);">{}
</span><span style="color: rgb(95, 158, 160);">Get-ADObject</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-SearchBase</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 128);">$rootdse</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">ConfigurationNamingContext</span><span style="color: rgb(0, 0, 0);">) </span><span style="color: rgb(95, 158, 160);">-LDAPFilter</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 0);">"(&amp;(objectclass=controlAccessRight)(rightsguid=*))"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Properties</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">displayName</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">rightsGuid</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">|</span><span style="color: rgb(0, 0, 0);"> 
</span><span style="color: rgb(255, 0, 0);">%</span><span style="color: rgb(0, 0, 0);"> {</span><span style="color: rgb(128, 0, 128);">$extendedrightsmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 128);">$_</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">displayName</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(139, 69, 19);">System.GUID</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 128);">$_</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">rightsGuid</span><span style="color: rgb(0, 0, 0);">}

</span>
</pre><p>Now that I have that in place, I can move forward with the actual delegation work. The below code allows the AD group named “Contoso Provisioning Admins” to create and delete user objects, modify their attributes, and reset their passwords. It also allows the AD group named “Contoso Service Desk” to reset user passwords in the top-level Contoso Users OU. </p><p>The tricky part comes when we have to create the <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">ActiveDirectoryAccessRule</a> that goes into the <a href="https://msdn.microsoft.com/en-us/library/5adsx0hb.aspx">AddAccessRule</a> method. This object has six different <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">constructors</a> and each can be used for a different use case.</p><pre><span style="color: rgb(0, 128, 0);">#Get a reference to the OU we want to delegate
</span><span style="color: rgb(128, 0, 128);">$ou</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">Get-ADOrganizationalUnit</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Identity</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 0);">"OU=Contoso Users,"</span><span style="color: rgb(255, 0, 0);">+</span><span style="color: rgb(128, 0, 128);">$domain</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">DistinguishedName</span><span style="color: rgb(0, 0, 0);">)
</span><span style="color: rgb(0, 128, 0);">#Get the SID values of each group we wish to delegate access to
</span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.Security.Principal.SecurityIdentifier</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(95, 158, 160);">Get-ADGroup</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">"Contoso Provisioning Admins"</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">SID</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$s</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.Security.Principal.SecurityIdentifier</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(95, 158, 160);">Get-ADGroup</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">"Contoso Service Desk"</span><span style="color: rgb(0, 0, 0);">)</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">SID</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(0, 128, 0);">#Get a copy of the current DACL on the OU
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">Get-ACL</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Path</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 128);">$ou</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">DistinguishedName</span><span style="color: rgb(0, 0, 0);">)
</span><span style="color: rgb(0, 128, 0);">#Create an Access Control Entry for new permission we wish to add
#Allow the group to write all properties of descendent user objects
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"WriteProperty"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Descendents"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"user"</span><span style="color: rgb(0, 0, 0);">]))
</span><span style="color: rgb(0, 128, 0);">#Allow the group to create and delete user objects in the OU and all sub-OUs that may get created
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"CreateChild,DeleteChild"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"user"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"All"</span><span style="color: rgb(0, 0, 0);">))
</span><span style="color: rgb(0, 128, 0);">#Allow the group to reset user passwords on all descendent user objects
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"ExtendedRight"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$extendedrightsmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"Reset Password"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Descendents"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"user"</span><span style="color: rgb(0, 0, 0);">]))
</span><span style="color: rgb(0, 128, 0);">#Allow the Service Desk group to also reset passwords on all descendent user objects
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">`</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$s</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"ExtendedRight"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$extendedrightsmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"Reset Password"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Descendents"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"user"</span><span style="color: rgb(0, 0, 0);">]))
</span><span style="color: rgb(0, 128, 0);">#Re-apply the modified DACL to the OU
</span><span style="color: rgb(95, 158, 160);">Set-ACL</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-ACLObject</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Path</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 0);">"AD:\"</span><span style="color: rgb(255, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">(<span style="color: rgb(128, 0, 128);">$</span></span><span style="color: rgb(139, 69, 19);">ou.DistinguishedName</span><span style="color: rgb(0, 0, 0);">))</span></pre><pre></pre><p>I’ll extend this example to another scenario;&nbsp; the ability to link Group Policies Objects. This bit of PowerShell grants the “Contoso Group Policy Admins” AD group the ability to modify the gplink and gpoptions attributes across the entire domain (thus allowing them to link <strong><u>pre-existing</u></strong> Group Policy Objects to OUs.</p><pre><span style="color: rgb(0, 128, 0);">#Provision the Group Policy Admins role
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">Get-ACL</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Path</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 128);">$rootdse</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">defaultNamingContext</span><span style="color: rgb(0, 0, 0);">)
</span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.Security.Principal.SecurityIdentifier</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(95, 158, 160);">Get-ADGroup</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 0);">"Contoso Group Policy Admins"</span><span style="color: rgb(0, 0, 0);">))</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">SID</span><span style="color: rgb(0, 0, 0);">
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> `<br></span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"WriteProperty"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"gplink"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"All"</span><span style="color: rgb(0, 0, 0);">))
</span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">AddAccessRule</span><span style="color: rgb(0, 0, 0);">((</span><span style="color: rgb(95, 158, 160);">New-Object</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(139, 69, 19);">System.DirectoryServices.ActiveDirectoryAccessRule</span><span style="color: rgb(0, 0, 0);"> `<br></span><span style="color: rgb(128, 0, 128);">$p</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"WriteProperty"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"Allow"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 128);">$guidmap</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(128, 0, 0);">"gpoptions"</span><span style="color: rgb(0, 0, 0);">]</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(128, 0, 0);">"All"</span><span style="color: rgb(0, 0, 0);">))
</span><span style="color: rgb(95, 158, 160);">Set-ACL</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-ACLObject</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 128);">$acl</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(95, 158, 160);">-Path</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(128, 0, 0);">"AD:\"</span><span style="color: rgb(255, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(128, 0, 128);">$rootdse</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(139, 69, 19);">defaultNamingContext</span><span style="color: rgb(0, 0, 0);">))</span>
</pre><p>&nbsp;</p><p>As you can see, it’s not pretty but it is possible. If you get familiar with the .NET <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">constructors</a> used when creating the <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx">ActiveDirectoryAccessRule</a> and the various enum values for <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryrights.aspx">ActiveDirectoryRights</a> and <a href="https://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectorysecurityinheritance.aspx">ActiveDirectorySecurityInheritance</a>, you could crank out your entire delegation structure with a few lines of PowerShell!</p><pre>&nbsp;</pre><pre>&nbsp;</pre>]]></content:encoded>
    </item>
  </channel>
</rss>