Managing Windows Local Groups with PowerShell
scottalanmiller last edited by
As with local users, we can manage local groups with PowerShell in a "PowerShell way" today. The commands for managing local users are part of the LocalAccounts commandlet, the same one that we use for managing local users.
It is important to note that these commandlets are not part of PowerShell proper and are not available in all PowerShell versions. Also, while this is the "PowerShell way" to do user management, older methods like the net commands are stand alone utilities and work equally well from PowerShell as from any other calling method.
List Local Groups
Get Details of Specific Local Group
Get-LocalGroupMember -Name administrators
Add Local User to a Local Group
Add-LocalGroupMember -Group administrators -Member sally
or you can have a comma delimited list of users...
Add-LocalGroupMember -Group administrators -Member sally, john, buck, mack, hank, betty
Add an Active Directory Domain User to a Local Group
Add-LocalGroupMember -Group administrators -Member "mydomain\roberta"
Create a New Local Group
New-LocalGroup -Name mynewgroup
Delete a Local Group
Remove-LocalGroup -Name mynewgroup
Rename a Local Group
Rename-LocalGroup -Name mynewgroup -NewName myrenamedgroup
Part of a series on Windows Systems Administration by Scott Alan Miller