{"id":1218,"date":"2013-03-24T15:03:44","date_gmt":"2013-03-24T15:03:44","guid":{"rendered":"https:\/\/pipe2text.com\/?page_id=1218"},"modified":"2013-12-24T14:12:02","modified_gmt":"2013-12-24T14:12:02","slug":"using-powershell-to-export-active-directory-group-members-to-a-cvs-file","status":"publish","type":"page","link":"https:\/\/pipe2text.com\/?page_id=1218","title":{"rendered":"Using PowerShell to export Active Directory Group Members to a CVS File"},"content":{"rendered":"<p>Hi all,<\/p>\n<p>In this article I will discuss how I use the Get-ADGroupMember cmdlet to get a list of Active Directory Group members and dump it to a csv file. You will need to have the Active Directory Module for PowerShell installed to\u00a0use this cmdlet. Once you have the\u00a0 Active Directory Module for PowerShell installed you can open PowerShell as Administrator and type the following to import the module (module will be imported automatically when executing the\u00a0&#8220;Get-ADGroupMember&#8221; cmdlet in PowerShell 3.0)<\/p>\n<p>\u201cImport-Module ActiveDirectory\u201d<\/p>\n<p>After you import the AD module type the following\u00a0changing\u00a0the identity\u00a0to reflect your group name and the path to export group members to a csv file in that directory:<\/p>\n<p>Get-ADGroupMember -identity &#8220;<em>Name of Group<\/em>&#8221; | select name | Export-csv -path <em>C:\\Output\\Groupmembers.csv<\/em> -NoTypeInformation<\/p>\n<p>You should now have a list of members by display name in a csv file located at <em>C:\\Output\\Groupmembers.csv.<\/em> If you wanted to list out the users by samaccountname you could just change out &#8220;name&#8221; after the select statement with &#8220;samaccountname&#8221;.<\/p>\n<p>Now lets say you are using nested groups. You will notice that your list will reflect the nested group name and no the members of the nested group. All you need to do in this case is add the -recursive parameter to enumerate all the nested group members and add them to the list. This would look as follows:<\/p>\n<p>Get-ADGroupMember -identity &#8220;<em>Name of Group<\/em>&#8221; -recursive | select name | Export-csv -path <em>C:\\Output\\Groupmembers.csv<\/em> -NoTypeInformation<\/p>\n<p>I hope this helps. If you have any questions or feedback please leave a comment.<\/p>\n<p>Related Links:<\/p>\n<p><strong><a title=\"Using PowerShell and Active Directory to Create a Server or Workstation Inventory\" href=\"https:\/\/pipe2text.com\/?page_id=899\">Using PowerShell and Active Directory to Create a Server or Workstation Inventory<\/a><\/strong><\/p>\n<p><strong><a title=\"Using PowerShell to find Stale Computers in Active Directory\" href=\"https:\/\/pipe2text.com\/?page_id=121\">Using PowerShell to find Stale Computers in Active Directory<\/a><\/strong><\/p>\n<p><strong><a title=\"Moving Stale Computers in Active Directory to an OU using PowerShell\" href=\"https:\/\/pipe2text.com\/?page_id=750\">Moving Stale Computers in Active Directory to an OU using PowerShell<\/a><\/strong><\/p>\n<p><a title=\"Using PowerShell and a Text File to Delete Multiple Active Directory Groups\" href=\"https:\/\/pipe2text.com\/?page_id=2067\"><strong>Using PowerShell and a Text File to Delete Multiple Active Directory Groups<\/strong><\/a><\/p>\n<p><a title=\"Using PowerShell and a CSV File to Create Multiple Active Directory Groups\" href=\"https:\/\/pipe2text.com\/?page_id=2334\"><strong>Using PowerShell and a CSV File to Create Multiple Active Directory Groups<\/strong><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all, In this article I will discuss how I use the Get-ADGroupMember cmdlet to get a list of Active Directory Group members and dump it to a csv file. You will need to have the Active Directory Module for &hellip; <a href=\"https:\/\/pipe2text.com\/?page_id=1218\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"class_list":["post-1218","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/pages\/1218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/pipe2text.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1218"}],"version-history":[{"count":17,"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/pages\/1218\/revisions"}],"predecessor-version":[{"id":2368,"href":"https:\/\/pipe2text.com\/index.php?rest_route=\/wp\/v2\/pages\/1218\/revisions\/2368"}],"wp:attachment":[{"href":"https:\/\/pipe2text.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}