Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Oneliner Microsoft Powershell Script Get members list from active directory group in excel

This is my tiny article on gathering members information from active directory groups using windows PowerShell in very easy, I have used one-liner script earlier for creating bulk ad users, This script will get all the members from group and export it to CSV, This is very handy when providing someone information. I am using 2 methods here to fetch group members information. Both scripts export members to CSV file. Marked values in the orange need to be changed as per your need.

Get-ADGroup Group1 | Get-ADGroupMember | Select-Object Name, SamAccountName, ObjectClass, distinguishedName | Export-Csv C:\Temp\Groupusers.csv

Get-ADGroup Group1 -Properties Members | Select-Object -ExpandProperty Members | Get-ADObject | Select-Object Name, ObjectClass, DistinguishedName |Export-Csv C:\Temp\Groupusers.csv

The best part is any user can fetch this information as needed, users cannot change any information but can retrieve easily but above scripts requires AD modules to be install and import using below URLs, 
Installing, importing and using any module in powershell
Different ways to bypass Powershell execution policy :.ps1 cannot be loaded because running scripts is disabled

microsoft powershell active directory domain controller, ad module, get-adgroup, select-object, get-adobject, group, user, members.png

CSV file can be opened easily in excel.

microsoft powershell active directory domain controller, ad module, excel, csv, get-adgroup, select-object, get-adobject, group, user, members.png

Useful articles
POWERSHELL: INSTALLING AND CONFIGURING ACTIVE DIRECTORY 
POWERSHELL ACTIVE DIRECTORY: ADD OR UPDATE (CHANGE) MANAGER NAME IN ORGANIZATION TAB OF USER
POWERSHELL ACTIVE DIRECTORY: ADD OR UPDATE PROXYADDRESSES IN USER PROPERTIES ATTRIBUTE EDITOR
Powershell one liner: Create multiple user accounts
Active Directory Powershell: Create bulk users from CSV file

Go Back

Comment

Blog Search

Page Views

1495598

Follow me on Blogarama