I could use some help. My Active Directory is 20 year old, its about to start buying legal alcohol and god knows where it's going from there...
All joking aside, Exchange has ravaged my AD DACLs. To the point Exchange isn't even working right. I built a lab with an identical AD structure but fresh on 2022-OS/2019-EX-CU12 just so I can see what the correct permissions look like.
GREAT! I see all the missing DACLS I need for proper operation once more. The problem? Have you ever tried to use Advanced Native Permission tooling for squirly stuff like Exchange stuff? It just locks up, god knows if I am even doing it right, ugh...
What I would rather do is this on the clean side:
$acl = get-acl -path "AD:DC=prod,DC=widgets,DC=corp"
$acl.Access | ? {$_.IdentityReference -like "*Exchange*" -or $_.IdentityReference -like "*Organization*"} | export-CliXml -Path c:\temp\ftw.xml
Then remove row records from the text file I don't need to import, for those I do I would modify the domain name in the xml file to match the production side:
$CleanACLs = Import-Clixml C:\temp\ftw.xml
$TestVictom = "AD:CN=Poor User,OU=Employees,DC=prod,DC=myCompany,DC=corp"
$acl = get-acl -path $TestVictom
#Testing just one ACL
$NewACE = ($CleanACLs)[0]
$acl.AddAccessRule($newACE)
Set-Acl -Path $TestVictom -AclObject $acl
However, my dreams were busted by this error on the "$acl.AddAccessRule($newACE)" line:
MethodException: Cannot convert argument "rule", with value: "System.DirectoryServices.ActiveDirectoryAccessRule", for "AddAccessRule" to type "System.DirectoryServices.ActiveDirectoryAccessRule": "Cannot convert the "System.DirectoryServices.ActiveDirectoryAccessRule" value of type "Deserialized.System.DirectoryServices.ActiveDirectoryAccessRule" to type "System.DirectoryServices.ActiveDirectoryAccessRule"."
It seems something as silly as the fact the import-clixml changing ALL of the objects to add the deserialized. is the issue. I am fairly sure the objects are identical otherwise. Ironically, I was using clixml to preserve object type.
Anyone got any magic to get these objects to not have the prefix of deserialized?
Otherwise, anyone have a decent way to export an AD object DACL to an editable text file, with a way to re-import? The only thing I need to do in the text file is remove unneeded rows (which I can technically filter on the source side) as well change the domain name of the IdentityReference).
Cheers!