- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 user in windows using PowerShell?
To create a new local user in the Windows operating system using PowerShell, we can use the New-LocalUser cmdlet. The below command will create the TestUser with no password.
New-LocalUser -Name TestUser -NoPassword
Output
Name Enabled Description ---- ------- ----------- TestUser True
TestUser account has been enabled here. To provide the password for the user, the password should be in the secure string format. We can pass the password as shown below.
$pass = "Admin@123" | ConvertTo-SecureString -AsPlainText -Force New-LocalUser -Name TestUser -Password $pass
The above commands will create the TestUser with the password. To add the password and account-related settings we can directly provide parameters but for ease, we will use the splatting method as shown below.
$Localuseraccount = @{ Name = 'TestUser' Password = ("Admin#123" | ConvertTo-SecureString -AsPlainText -Force) AccountNeverExpires = $true PasswordNeverExpires = $true Verbose = $true } New-LocalUser @Localuseraccount
The above command will create testuser with a password and set its property to Account Never Expires and Password Never Expires.
- Related Articles
- How to create a new local group using PowerShell?
- How to enable or disable local user on Windows OS using PowerShell?
- How to change the local user account password using PowerShell?
- How to set the local user account settings using PowerShell?
- How to find the locked local user accounts using PowerShell?
- How to get the disabled local user accounts using PowerShell?
- How to delete the local group from the windows system using PowerShell?
- How to add the user to the local Administrators group using PowerShell?
- How to create a User Menu in PowerShell?
- How to create a new Azure resource group using PowerShell?
- How to add users and groups to the local groups on Windows System using PowerShell?
- How to stop a windows service using PowerShell?
- How to start a windows service using PowerShell?
- How to share a windows folder using PowerShell?
- How to Get Windows features using PowerShell?

Advertisements