A simple script to create and add a local administrator to a Windows VM.
$user = Read-Host -Prompt 'Input your username here' ? Add-Type -Assembly System.Web $pass=[Web.Security.Membership]::GeneratePassword(14,0) NET USER $user "$pass" /ADD /y NET LOCALGROUP "Administrators" "$user" /add WMIC USERACCOUNT WHERE "Name='$user'" SET PasswordExpires=FALSE ? Write-Host "Username: $user" -backgroundcolor black Write-Host "Password: $pass" -foregroundcolor red -backgroundcolor black Write-host "Server: $env:computername" -backgroundcolor black Write-host IPaddress: (Get-NetIPAddress | where {$_.AddressFamily -eq "IPv4" -and $_.IPAddress -ne "127.0.0.1"} | select IPAddress).IPAddress -backgroundcolor black