Create Local User PowerShell

Create a local Admin User in the device with a pre-defined password using this PowerShell Script. You can later change the username and password both. The user will then be a part of the administrator group.

Syntax

$Username = “Infrassist”
$Password = “local@DM!N”

$group = “Administrators”

$adsi = [ADSI]”WinNT://$env:COMPUTERNAME”
$existing = $adsi.Children | where {$_.SchemaClassName -eq ‘user’ -and $_.Name -eq $Username }

if ($existing -eq $null) {

Write-Host “Creating new local user $Username.”
& NET USER $Username $Password /add /y /expires:never

Download Full Script

Share Script:

Purpose:Create Local User as part of the Administrator Group
Modification:
Type:PowerShell (.ps1)
Compatibility:Run with PowerShell
Tags:
Reference link: