Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

How to get members of BUILTIN\ADMINISTRATORS with Powershell

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

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

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.

Working...

Post a comment on How to get members of BUILTIN\ADMINISTRATORS with Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer