Created
September 22, 2020 07:21
-
-
Save techdecline/09f06d712a64c3c42b802badd99aa9d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Variables | |
| ########### | |
| $siteServerName = "CMTP_Server1" | |
| $domainLDAP = "dc=decline,dc=lab" | |
| # System Management Container | |
| ############################# | |
| New-ADObject -Name "System Management" -Type Container -Path ("Cn=system," + $domainLDAP) | |
| $containerDN = "CN=System Management,Cn=system," + $domainLDAP | |
| $siteServerSID = (Get-ADComputer $siteServerName).SID | |
| $aclObj = Get-Acl AD:\${containerDN} | |
| $objACE = New-Object System.DirectoryServices.ActiveDirectoryAccessRule($siteServerSID,"GenericAll","Allow", [System.Security.AccessControl.InheritanceFlags]::ContainerInherit, [guid]'00000000-0000-0000-0000-000000000000') | |
| $aclObj.AddAccessRule($objACE) | |
| Set-acl -AclObject $aclObj "AD:${containerDN}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment