{"id":601,"date":"2013-10-08T18:25:15","date_gmt":"2013-10-08T18:25:15","guid":{"rendered":"http:\/\/dollarunderscore.azurewebsites.net\/?p=601"},"modified":"2017-06-05T20:49:00","modified_gmt":"2017-06-05T18:49:00","slug":"get-local-groups-and-their-members-with-powershell","status":"publish","type":"post","link":"https:\/\/p0wershell.com\/?p=601","title":{"rendered":"Get local groups and their members with PowerShell"},"content":{"rendered":"<p>The Active Directory Module for PowerShell is great. You can do almost anything with it, but every now and then you might need to list the local groups and their members on a server\/client, and that is harder&#8230;<\/p>\n<p>To achieve this I wrote a couple of advanced functions to simplify the task. &#8220;Get-LocalGroup&#8221; and &#8220;Get-LocalGroupMember&#8221;.<\/p>\n<p>The usage should be pretty simple, but to give you an idea:<\/p>\n<pre>PS H:\\&gt; Get-LocalGroup\r\n\r\nComputerName GroupName                                   SID\r\n------------ ---------                                   ---\r\nMyMachine    Administrators                              S-1-5-32-544\r\nMyMachine    Backup Operators                            S-1-5-32-551\r\nMyMachine    Cryptographic Operators                     S-1-5-32-569\r\nMyMachine    Distributed COM Users                       S-1-5-32-562\r\nMyMachine    Event Log Readers                           S-1-5-32-573\r\nMyMachine    Guests                                      S-1-5-32-546\r\nMyMachine    IIS_IUSRS                                   S-1-5-32-568\r\nMyMachine    Network Configuration Operators             S-1-5-32-556\r\nMyMachine    Performance Log Users                       S-1-5-32-559\r\nMyMachine    Performance Monitor Users                   S-1-5-32-558\r\nMyMachine    Power Users                                 S-1-5-32-547\r\nMyMachine    Remote Desktop Users                        S-1-5-32-555\r\nMyMachine    Replicator                                  S-1-5-32-552\r\nMyMachine    Users                                       S-1-5-32-545\r\n\r\n\r\nPS H:\\&gt; Get-LocalGroup | where GroupName -eq Administrators | Get-LocalGroupMember\r\n\r\nDomain    GroupName      Type  Name\r\n------    ---------      ----  ----\r\nMyMachine Administrators User  Administrator\r\nMyDomain  Administrators Group Domain Admins\r\nMyDomain  Administrators Group TheAdmins\r\n\r\n<\/pre>\n<p><em><strong>The code is available <a title=\"Get-LocalGroup and Get-LocalGroupMember\" href=\"https:\/\/p0wershell.com\/wp-content\/uploads\/2014\/07\/Get-local-groups-and-members.ps1_.txt\">here<\/a>.<\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Active Directory Module for PowerShell is great. You can do almost anything with it, but every now and then you might need to list the local groups and their members on a server\/client, and that is harder&#8230; To achieve this I wrote a couple of advanced functions to simplify the task. &#8220;Get-LocalGroup&#8221; and &#8220;Get-LocalGroupMember&#8221;. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[391,21],"tags":[411,401,421],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3Zj0A-9H","_links":{"self":[{"href":"https:\/\/p0wershell.com\/index.php?rest_route=\/wp\/v2\/posts\/601"}],"collection":[{"href":"https:\/\/p0wershell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p0wershell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p0wershell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p0wershell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=601"}],"version-history":[{"count":0,"href":"https:\/\/p0wershell.com\/index.php?rest_route=\/wp\/v2\/posts\/601\/revisions"}],"wp:attachment":[{"href":"https:\/\/p0wershell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p0wershell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=601"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p0wershell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}