AndersonPatricio.ca

A Microsoft Unified Communications resource blog

Recent Posts

Search by Topic

Email Notifications

Blogroll

My Microsoft KBs

.:. About me..

Microsoft Community

Andy's Toolbox

Archives

Ads

Quick hint: Listing all users from a specific OU using PowerShell

sans-titre I was asked Today how to create a list of all users from a specific OU with their Display Names and their logon names using PowerShell?

There are several ways to get the results, a simple one when you know the location of the OU (in our example here is apatricio.local/Argentina) is to run the following cmdlet. Make sure that you are logged on a Domain Controller or at least a server with AD tools installed.

Import-Module ActiveDirectory
Get-ADUser -SearchBase "OU=Argentina,dc=apatricio,dc=local" -Filter * -ResultSetSize 5000 | Select Name,SamAccountName

That will give you a list of the users, if you want to export that, just add  | export-csv C:\Argentina-users.csv to the end of the previous cmdlet and open the file afterwards and the same can be open in Excel as well.

Cheers,
Anderson Patricio
http://www.andersonpatricio.ca
http://www.andersonpatricio.org (Portuguese)
Twitter: @apatricio

Leave a Comment

(required) 

(required) 

(optional)
 

(required) 

If you can't read this number refresh your screen
Enter the numbers above: