Files

7 lines
443 B
PowerShell
Raw Permalink Normal View History

2024-03-13 15:12:24 -04:00
If ( $(Get-CimInstance -ClassName Win32_OperatingSystem -Property ProductType | Select-Object -ExpandProperty ProductType) -eq "2" ) {
Write-Output "Cannot create or modify local accounts on a domain controller"
2024-03-13 15:12:24 -04:00
Return
}
Write-Output "Setting local Administrator password"
Try { net user Administrator $Password /times:all /active:yes }
Catch { Write-Error "Could not set local Administrator password`n"+$_.Exception.Message ; Exit 1 }