From Chris H
"hey the add admin account script didnt work
made some adjustments not sure how to post to your git
basically the end regedit failed until I changed it to create the directory"
``# Wrote by jgerman03 - use this script to create a new user account, set as a local administrator, with password, hidden from login (if needed)
Change the following as needed "username" & "password"
Run this script on demand or a scheduled basis within NinjaRMM as SYSTEM
$Username = "testadmin"
$Password = "password"
$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
Write-Host "Adding local user $Username to $group."
& NET LOCALGROUP $group $Username /add
}
else {
Write-Host "Setting password for existing local user $Username."
$existing.SetPassword($Password)
}
Sets password as never expires
Write-Host "Ensuring password for $Username never expires."
& WMIC USERACCOUNT WHERE "Name='$Username'" SET PasswordExpires=FALSE
Hides User Account from Login page
$path1 = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
$path2 = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts'
$path3 = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList'
$value = "0"
New-Item $path1 -Name "SpecialAccounts" -type Directory
New-Item $path2 -Name "UserList" -type Directory
New-ItemProperty -Path $path3 -Name $Username -Value $value -PropertyType DWORD -Force | Out-Null`