# Get Local admins with domain

**URL:** <https://forums.powershell.org/t/get-local-admins-with-domain/7554>\
**Category:** PowerShell Help\
**Created:** [November 18, 2016, 11:49am UTC](https://forums.powershell.org/t/get-local-admins-with-domain/7554 "2016-11-18T11:49:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![goneposhing](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@goneposhing](https://forums.powershell.org/u/goneposhing)\
**Post date:** [November 18, 2016, 11:49am UTC](https://forums.powershell.org/t/get-local-admins-with-domain/7554/1 "2016-11-18T11:49:22Z")

</div>

Hi fellow Poshers,

I have been looking all over the InterTubes for a way to adjust this code to return the domain for the members within the local admins group.

```
$group =[ADSI]"WinNT://$computer/Administrators" 
$members = @($group.psbase.Invoke('Members'))
$LocalAdmins = $members | ForEach-Object {$_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null) }
```

Running the above code will give me a list like below:  
admins  
admins

And what I am looking for is:  
domain1\admins  
domain2\admins

Due to restrictions I don’t have access to wsman on windows 2008 server and cannot invoke-command, otherwise I would use the method mentioned in article “[https://powershell.org/2013/04/02/get-local-admin-group-members-in-a-new-old-way/](https://powershell.org/2013/04/02/get-local-admin-group-members-in-a-new-old-way/)”

Additionally if any of you deep web ninjas are feeling particularly randy, I’d love to understand what is going on in this command "$_.GetType().InvokeMember(‘Name’, ‘GetProperty’, $null, $_, $null) "

---

<div class="post-metadata">

**Author:** ![matt-howard](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/matt-howard/32/247_2.png) [@matt-howard](https://forums.powershell.org/u/matt-howard)\
**Post date:** [November 18, 2016, 12:23pm UTC](https://forums.powershell.org/t/get-local-admins-with-domain/7554/2 "2016-11-18T12:23:55Z")

</div>

Take a look at this blog post from Jeff Hicks. He uses the ADSI method to get the local admin group members and display their domain name: [Get Local Group Members with PowerShell • The Lonely Administrator](http://jdhitsolutions.com/blog/powershell/4908/get-local-group-members-with-powershell)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:39pm UTC](https://forums.powershell.org/t/get-local-admins-with-domain/7554/3 "2024-05-16T20:39:59Z")

</div>


