Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to Export Active Directory Group Members with Powershell Get-ADGroupMember

26 June,2014 by Tom Collins

Question: How can I export Active Directory Group members? Also, if there are sub-groups , how can I get a list of members of AD group in Powershell? 

Answer:  To access the Active Directory through Powershell,  an efficient method  is to install the  Active Directory Module for Powershell .

The Get-ADGroupMember module gets the Active Directory Group members

 

Import-Module ActiveDirectory
Get-ADGroupMember -identity “Group name” | select name | Export-csv -path C:\ADGroupmembers.csv –NoTypeInformation

 

If there are nested groups , within the group you’re checking , then use the –recursive parameter.

The –recursive parameter will enable an iteration of all the nested groups  , reporting on the members. The nested group members are added to the result list

 

Get-ADGroupMember -identity “Group name” -recursive | select name | Export-csv -path C:\ADGroupmembers.csv –NoTypeInformation

 

 

The above commands will look for AD groups within the current domain . If the requirement is to check in another domain in the same AD forest than you'll need to use the -server switch 

 

Import-Module ActiveDirectory Get-ADGroupMember -identity “Group name” -server "another_domain"| select name | Export-csv -path C:\ADGroupmembers.csv –NoTypeInformation


Read More

How to get all Domain Controllers in Active Directory Forest with ...

Powershell , Excel charts and data presentation - SQL Server DBA

Powershell – adding multiple worksheets to Excel ... - SQL Server DBA

Export-CSV Powershell - SQL Server DBA

 

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to Export Active Directory Group Members with Powershell Get-ADGroupMember


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer