
close
close
The Active Directory drive (AD:) in PowerShell gives administrators an easy way to explore AD from the command line, in much the same way you would list the directory contents of a hard disk using the DIR command in DOS. Let’s see how to connect to the AD drive and the commands used to navigate through it.
You’ll see a list of the forest’s partitions. To do anything useful, we need to connect to the domain partition using the set-location cmdlet.
advertisment
The distinguished name (DN) of your domain can be seen in the output of the previous DIR command. The DNS name of my Active Directory domain is ad.contoso.com, therefore the domain’s DN is dc=ad,dc=contoso,dc=com. So the command should look like Set-Location “dc=ad,dc=contoso,dc=com”. Again the PowerShell prompt will change, in this example to PS AD:\dc=ad,dc=contoso,dc=com>.
Note that if you want to change the working location to an Organizational Unit (OU) instead of a container, change cn to ou. For example, to connect to the HR OU, the command might look like Set-Location “ou=hr users”.
In exactly the same way you navigate back up a directory tree in DOS, you can use the set-location command to move back up a level. For example, to move from cn=users,dc=ad,dc=contoso,dc=com up one level to dc=ad,dc=contoso,dc=com, type set-location followed by two dots in the PowerShell window, like so: set-location ..
advertisment
If you want to move in and out of the AD drive, or move around the AD drive but need to frequently return to a particular location, you can use the push-location and pop-location cmdlets:
More from Russell Smith
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Active Directory
Best Practices for Installing Active Directory Domain Controllers in a Virtual Machine
Apr 15, 2022 | Michael Taschler
Microsoft Details Efforts to Fight Russian Cyber Attacks Targeting Ukraine
Apr 8, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group