From 04d714cc5bbba50f6890dc1378d9399f50f33fe8 Mon Sep 17 00:00:00 2001 From: ek-dyoder Date: Wed, 8 Oct 2025 17:19:41 -0400 Subject: [PATCH] fix error handling in Set-DefaultAdministratorCredentials script --- Set-DefaultAdministratorCredentials.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Set-DefaultAdministratorCredentials.ps1 b/Set-DefaultAdministratorCredentials.ps1 index ddc4608..c46a88d 100644 --- a/Set-DefaultAdministratorCredentials.ps1 +++ b/Set-DefaultAdministratorCredentials.ps1 @@ -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 } \ No newline at end of file +Catch { Write-Error "Could not set local Administrator password`n"+$_.Exception.Message ; Exit 1 } \ No newline at end of file