How to create a local user in windows server 2016 | windows 10 | windows 7 operating system, here are the simple steps.
Windows administrators as part of their routine daily tasks they deal with many servers and also create new local users on remote computers. It is easy to create if there are only a few computers one can login and create it, imagine if there are hundreds of servers and one has to login to each server and create a local account means it’s an extremely painful task, The below shortcode creates a local system account with a password defined on remote computers.
Before we write a script here Microsoft has provided important commands to deal with all local accounts, here are the commands list.
Get-Command -Module Microsoft.PowerShell.localaccouts
Listing all the Local user accounts commands.
Get-Command -Module Microsoft.PowerShell.localaccounts
Creating a local account on a single computer.
$Password = Read-Host –AsSecureString New-LocalUser "John" -Password $Password -FullName "Valaboju John" -Description "Normal Acocunt"
When you run the script it prompts you to enter the password for this local account John, the screenshots below.
See the below screenshot it has created a local user John on the local machine
Validation using the command lusrmgr command.
How to create a local user account on remote computers
Let’s see how to create a local account on multiple remote computers.
We need to create a file for storing all the servers or multiple machines list, I named it
as Allservers.txt for and saved it in my local machine c:\temp\Allservers.txt
$Allserers = get-content -path "C:\temp\Allservers.txt" $Password = Read-Host –AsSecureString foreach ($oneserver in $allservers) { Invoke-Command -ComputerName $onecomputer -ScriptBlock {New-LocalUser "John" -Password $Password -FullName "Valaboju John" -Description "Normal Acocunt"} }
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply