Skip to content

Instantly share code, notes, and snippets.

@Charasala
Charasala / Create-Administrator.ps1
Created February 18, 2021 14:44 — forked from ducas/Create-Administrator.ps1
Create a local administrator account using PowerShell
$Username = "su"
$Password = "password"
$group = "Administrators"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {