Local groups are an essential part of Windows systems, allowing administrators to manage user access to resources on the local machine. With the help of PowerShell, creating local groups is a simple task. The New-LocalGroup command is a powerful tool that allows administrators to quickly create and manage local groups.

What is New-LocalGroup?

The New-LocalGroup command is a Windows PowerShell command that allows administrators to create and manage local groups. It is a part of the Windows Management Framework, which is a set of tools for managing Windows systems. The command can be used to create new local groups, add members to existing groups, and modify existing groups.

Syntax and Parameters

The syntax for the New-LocalGroup command is as follows:

New-LocalGroup [-Name] <String> [-Description <String>] [-Members <String[]>] [-Scope <LocalGroupScope>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

The parameters for the command are as follows:

Name The name of the local group to create
Description A description of the local group
Members A list of users or groups to add to the local group
Scope The scope of the local group (local or global)
Force Forces the command to run without prompting for confirmation
WhatIf Shows what would happen if the command were to run
Confirm Prompts for confirmation before running the command

Inputs and Outputs

The New-LocalGroup command takes the following inputs:

  • The name of the local group to create
  • A description of the local group
  • A list of users or groups to add to the local group
  • The scope of the local group (local or global)

The command does not produce any output.

Examples

The following examples demonstrate how to use the New-LocalGroup command:

  • To create a local group called “TestGroup” with the description “Test Group”, use the following command: New-LocalGroup -Name "TestGroup" -Description "Test Group"
  • To create a local group called “TestGroup” with the description “Test Group” and add the user “User1” to the group, use the following command: New-LocalGroup -Name "TestGroup" -Description "Test Group" -Members "User1"
  • To create a global group called “TestGroup” with the description “Test Group” and add the user “User1” to the group, use the following command: New-LocalGroup -Name "TestGroup" -Description "Test Group" -Members "User1" -Scope Global

Tips for Using New-LocalGroup

The New-LocalGroup command is a powerful tool for creating and managing local groups. Here are some tips for using the command:

  • Make sure to specify the scope of the group when creating it. The default scope is local, but the command can also be used to create global groups.
  • Use the Force parameter to run the command without prompting for confirmation.
  • Use the WhatIf parameter to see what would happen if the command were to run.
  • Use the Confirm parameter to prompt for confirmation before running the command.

Conclusion

The New-LocalGroup command is a powerful tool for creating and managing local groups. With the help of PowerShell, administrators can quickly create and manage local groups. By following the syntax and parameters outlined in this article, administrators can easily create and manage local groups with the New-LocalGroup command.

Leave a Reply