13 January,2022 by Tom Collins
Question: How can I obtain a list of BUILTIN\Administrators members using Powershell ?
Answer: There is a Powershell cmdlet Get-LocalGroupMember. This cmdlet will give you a basic listing , it is then possible to perform a range of data manipulations according to your requirements . Here are some examples
--Example1 : get all members of the Server Local Administrators group
Get-LocalGroupMember -Group "Administrators"
--Example 2: get all members of a Server Local Administrators group on a Remote server, get-localgroupmember doesn't currently support -computer switch
Invoke-Command -ComputerName [computer] -ScriptBlock {Get-LocalGroupMember -Name "Administrators"}
--Example 3: get all members of the Server Local Administrator Group , including SID & Object Class
Get-LocalGroupMember -Group "Administrators" | Select-Object *
--Example 4: get all members of the Server Local Administrator Group ,sort by Name
Get-LocalGroupMember -Group "Administrators" | Sort-Object Name
--Example 5 : get or check members from the Server Local Administrator Group , where a specific member exists.Using Powershell Where-Object
Invoke-Command -ComputerName MyServer1 -ScriptBlock {Get-LocalGroupMember -Group "Administrators" | Select-Object Name | Where-Object {$_.Name -eq 'MYDOMAIN\my_ad_Group'}}
More reading on Powershell & Users
How to extract Active Directory users with Get-ADGroup and Get-ADGroupMember
How to find Active Directory users with Get-ADUser search filter
How to list Windows users with Powershell
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |