Active Directory get list of users with PowerShell

Today, I had task how to export list of users from specific group.

So it’s easy:
1. Open PowerShell
2. Run:
Import-Module ActiveDirectory //this will load Active Directory libs
3. Get-ADGroupMember -identity “Enterprise Admins” | select name | Export-csv -path C:\Output\EnterpriseAdmins.csv -NoTypeInformation

With this command you don’t need to specify whole object path, just name, if you have another group name – just replace Enterprise Admins with your group name. Please make sure you have Output directory on drive C, otherwise you will got next:
Export-Csv : Could not find a part of the path 'C:\output\EnterpriseAdmins.csv'.
At line:1 char:74
+ Get-ADGroupMember -identity "Enterprise Admins"| select name | Export-csv <<<< -path c:\output\EnterpriseAdmins.csv -NoTypeInformation
+ CategoryInfo : OpenError: (:) [Export-Csv], DirectoryNotFoundEx ception
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.Ex portCsvCommand

I hope this will help you.

Advertisements

About nicoljako

CTO of Exelegent, sysadmin, architect of IT infrastructures​
This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Google+ photo

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

Connecting to %s