Creating Local User Accounts on 6 Remote Computers in a Windows Workgroup
In this article, we will discuss how to create local user accounts on six remote computers that are part of a Windows workgroup. This process can be automated using a simple script that prompts the user for the account details to be created.
Prerequisites
- All remote computers must be part of the same Windows workgroup.
- You must have administrative access to all remote computers.
- PowerShell remoting must be enabled on all remote computers.
Script Overview
The script we will create will prompt the user for the following details:
- The username to be created
- The password for the new user account
- The name of the remote computer where the account will be created
The script will then use the New-LocalUser cmdlet to create the new user account on the specified remote computer.
Script Details
Here is an example script that demonstrates how to create a local user account on a remote computer:
$username = Read-Host -Prompt "Enter the username"
$password = Read-Host -Prompt "Enter the password" -AsSecureString
$computerName = Read-Host -Prompt "Enter the name of the remote computer"
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Invoke-Command -ComputerName $computerName -Credential $credential -ScriptBlock {
New-LocalUser -Name $using:username -Password $using:password
}
To create local user accounts on six remote computers, you can modify the script as follows:
$computerNames = "computer1", "computer2", "computer3", "computer4", "computer5", "computer6"
$username = Read-Host -Prompt "Enter the username"
$password = Read-Host -Prompt "Enter the password" -AsSecureString
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
foreach ($computerName in $computerNames) {
Invoke-Command -ComputerName $computerName -Credential $credential -ScriptBlock {
New-LocalUser -Name $using:username -Password $using:password
}
}In this article, we have discussed how to create local user accounts on six remote computers that are part of a Windows workgroup. We have provided a script that prompts the user for the account details and uses the New-LocalUser cmdlet to create the new user account on the specified remote computer.