Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to add members to the Administrators group with Powershell

15 September,2021 by Tom Collins

Question: I want to create a Powershell script to add an  Active Directory Group to the the local Administrator Group on a group of servers.  The login privileges to execute the script would be Administrator. 

What is the Powershell command to add the group along with an example

Answer:  Powershell has a group of cmdlets designed to manage membership of local groups.    The first one to check is the cmdlet returning the current membership of the Local Administrators group

--Get-LocalGroupMember returns members from a local group. This example is using the Administrators group

    Get-LocalGroupMember -Group "Administrators"


-- Add-LocalGroupMember  will add members to a local group

Add-LocalGroupMember -Group "Administrators" -Member "MYDOMAIN\myADGroup"


If the member already exists in the Local Administrators group  you will see a message similar to : 

Add-LocalGroupMember : MYDOMAIN\myADGroup is already a member of group Administrators.
At line:1 char:1
+ Add-LocalGroupMember -Group "Administrators" -Member "MYDOMAIN\myADGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Administrators:String) [Add-LocalGroupMember], MemberExistsException
+ FullyQualifiedErrorId : MemberExists,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand




Author: Tom Collins (


Verify your Comment

Previewing your Comment

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

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.


Post a comment on How to add members to the Administrators group with Powershell | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer