
close
close
Chance to win $250 in Petri 2023 Audience Survey
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.
Table of Contents
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.
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 ..
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 in Active Directory
Microsoft Releases Update to Streamline Exchange Online License Assignments
Jan 24, 2023 | Rabia Noureen
How to Export Active Directory Users to CSV With PowerShell and ADUC
Jan 23, 2023 | Michael Reinders
ManageEngine ADSelfService Plus: Protect On-Premises and Cloud Services from Password Attacks with Multi-factor Authentication
Jan 12, 2023 | Michael Reinders
Microsoft 365 to Launch New $1.99/Month Basic Subscription with 100 GB of OneDrive Storage
Jan 11, 2023 | Rabia Noureen
Samsung Releases Server-Side Fixes for Microsoft Intune Android 13 Enrollment Issues
Dec 22, 2022 | Rabia Noureen
Most popular on petri