fix error handling in Set-DefaultAdministratorCredentials script

This commit is contained in:
2025-10-08 17:19:41 -04:00
parent 31312fb510
commit 04d714cc5b
+2 -2
View File
@@ -1,7 +1,7 @@
If ( $(Get-CimInstance -ClassName Win32_OperatingSystem -Property ProductType | Select-Object -ExpandProperty ProductType) -eq "2" ) {
Microsoft.Powershell.Utility\Write-Output "Cannot create or modify local accounts on a domain controller"
Write-Output "Cannot create or modify local accounts on a domain controller"
Return
}
Write-Output "Setting local Administrator password"
Try { net user Administrator $Password /times:all /active:yes }
Catch { Write-Error $_.Exception.Message }
Catch { Write-Error "Could not set local Administrator password`n"+$_.Exception.Message ; Exit 1 }