To check the amount of PCs (computers) and users inside a specific Organizational Unit (OU) in Active Directory, you essentially have a couple of options at your disposal. One approach is using the graphical Active Directory Users and Computers (ADUC) tool, and another is employing PowerShell commands, which is more efficient and flexible, especially for larger environments or when you need to script or automate the process. Below are the steps for both methods:
Using Active Directory Users and Computers (ADUC)
-
Open ADUC: Press Windows + R, type dsa.msc, and hit Enter. This opens the ADUC snap-in.
-
Enable Advanced Features: In the ADUC window, go to the "View" menu and make sure "Advanced Features" is checked. This ensures you see all the object types and properties.
-
Navigate to the Specific OU: In the left pane, navigate through the domain and find the OU you're interested in.
-
Manually Checking Counts:
- For Users: Click on the OU, and in the right pane, you can see all objects. You may need to filter or adjust the view to see only users by right-clicking in the right pane, selecting
Filter Options, and setting the appropriate filters.
- For Computers: Repeat the above step but adjust the filter to see only computers.
Note: This method does not directly give you a count; you'll have to manually count the entries or use export options to pull the data into a format (like CSV) that makes counting easier.
Using PowerShell
For more accuracy and efficiency, especially in larger directories, using PowerShell is recommended.
-
Open PowerShell with AD Module:
- First, ensure you're on a computer that has the Active Directory module for PowerShell installed (like a domain controller or a workstation with RSAT installed).
- Open PowerShell as an administrator.
-
Run Commands to Get Counts:
Get-ADUser -Filter * -SearchBase "OU=YourOU,DC=yourdomain,DC=com" | Measure-Object | Select-Object -ExpandProperty Count
Replace "OU=YourOU,DC=yourdomain,DC=com" with the actual distinguished name (DN) of your OU.
Get-ADComputer -Filter * -SearchBase "OU=YourOU,DC=yourdomain,DC=com" | Measure-Object | Select-Object -ExpandProperty Count
Again, replace "OU=YourOU,DC=yourdomain,DC=com" with the actual DN of your OU.
These PowerShell commands query Active Directory for users and computers in the specified OU and count them. The -Filter * argument means it matches all objects; adjust this as necessary to refine your search based on specific attributes. The Measure-Object cmdlet is then used to count the resulting objects, and Select-Object -ExpandProperty Count displays just the count number.
By modifying the SearchBase parameter, you can target any specific OU within the directory. PowerShell commands offer powerful filtering and scripting capabilities for managing and reporting Active Directory objects.