@jaredbusch said in Anyone have a powershell line to create a new admin account:
I have a handful of Windows 7 machiens not on a domain.
I want to put a new Admin account on them.
The current user accounts have admin rights, which I will remove, I have ScreenConnect installed and running with admin perms. So I can pop a powershell via the ScreenConnect command window easily to do this.
not tested... maybe this thread can help with PS 2.0. Quoting code here:
# Create new local Admin user for script purposes
$Computer = [ADSI]"WinNT://$Env:COMPUTERNAME,Computer"
$LocalAdmin = $Computer.Create("User", "LocalAdmin")
$LocalAdmin.SetPassword("Password01")
$LocalAdmin.SetInfo()
$LocalAdmin.FullName = "Local Admin by Powershell"
$LocalAdmin.SetInfo()
$LocalAdmin.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD
$LocalAdmin.SetInfo()