- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a new local group using PowerShell?
To create a new local group on the local or the remote system using PowerShell, we can use the NewLocalGroup command.
Example
New-LocalGroup -Name "TestGroup" -Description "Test Group"
Output
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 }
Advertisements