PowerShell: List everything on a OU in a one line

To list all users in a OU, we can get it using Get-ADUser cmdlet. See the example below. (replace OU path in LDAP format to your own stuff and “Import-Module ActiveDirectory” before you run it).

Get-ADUser -Filter * -SearchBase “cn=Users,dc=company,,dc=com” -properties title, department| Select-Object name,title,department

Now what if you want everything (Users, Groups, Contacts, etc.,) from an OU. To get everything from a OU, use Get-ADObject cmdlet. See example below.

Get-ADObject -Filter * -SearchBase “cn=Users,dc=company,dc=com” -properties description | Select-Object name, objectclass, description


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s