Use Get-Acl and Set-Acl with a specified Active Directory domain controller using PSDrive

When you use Active Directory commands such as Get-ADObject and Get-ADUser you'll notice there is a -Server switch you can use to specify a domain controller to use for the operation.

This switch isn't however available for the Get-Acl and Set-Acl commands. You may want to use a specific domain controller for example if you're setting the security descriptor of an object you've just created and the object may not have replicated yet.

Get-Acl and Set-Acl however use the Active Directory PSDrive AD: which performs a serverless bind when you run the Import-Module ActiveDirectory command as you can see in the screenshot.

PSDrive created

Running the command Get-PSDrive AD displays the following, showing that the default AD: drive does not have a server specified.

No Server Specified

Changing the default AD: drive probably isn't a good idea however we can create a new drive.

New-PSDrive -Name AD2 -PSProvider ActiveDirectory -Server "demo2022-dc02" -Scope "Script" -root "//RootDSE/"

And as we can see we can now see a server specified.

Server Specified

We can now issue the Get-Acl command using the new AD2 drive

Get-Acl -Path "AD2:DC=demo2022,DC=int" | SELECT *


Get-Acl output


You can easily prove that the command is using the specific domain controller by pausing that domain controller (if it's a VM) and the command will fail.


 
While you're here -
Why not check out our 
Active Directory Documentation Tool?









Comments

  1. Please comment if this has been helpful or if you have any questions.

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Windows Server 2019 desktop icons such as My Computer, Windows cannot access the specified device, path, or file.