How to create a new local group using PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To create a new local group on the local or the remote system using PowerShell, we can use the NewLocalGroup command. 


New-LocalGroup -Name "TestGroup" -Description "Test Group"


Name       Description
----       -----------
TestGroup Test Group

You can verify it from the Computer Management GUI.

To create the local group on the remote systems, you can use Invoke-Command. For example,

Invoke-Command -ComputerName Test1-Win2k12,Test1-Win2k16 -ScriptBlock{
   New-LocalGroup -Name 'TestGroup' -Description 'New Test Group'

The above command will create a New Local group named ‘TestGroup’ on the remote systems, Test1-Win2k12, and Test1-Win2k16.

New-LocalGroup command is available in the module Microsoft.PowerShell.LocalAccounts which is part of the PowerShell version 5.1 or higher versions. If you have the older PowerShell version system then you can use the cmd command.

Net localgroup 'TestGroup2' /add

For the remote servers,

Invoke-Command -ComputerName Test1-Win2k12, Test1-Win2k16 -ScriptBlock{
   Net Localgroup ‘TestGroup2’ /add
Published on 02-Nov-2020 15:17:41