From eca4f24e11d9bbee83a123824548d911e165085c Mon Sep 17 00:00:00 2001 From: vitya Date: Mon, 8 Jun 2026 13:41:13 +0300 Subject: [PATCH] fix(decommission): prompt for sa password instead of bash/pass in elevated PS In an elevated shell `bash` resolves to WSL bash (not Git bash where `pass` lives); its stderr proxy warning + ErrorActionPreference=Stop aborted the script at the pass-fetch line. Replaced with a hidden Read-Host prompt; set ErrorActionPreference=Continue around the docker teardown so native stderr can't abort it. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../finish-elevated.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/decommission-windows-recovery-host/finish-elevated.ps1 b/scripts/decommission-windows-recovery-host/finish-elevated.ps1 index 5b5a00f..f9fd608 100644 --- a/scripts/decommission-windows-recovery-host/finish-elevated.ps1 +++ b/scripts/decommission-windows-recovery-host/finish-elevated.ps1 @@ -19,8 +19,11 @@ Import-Module WebAdministration # ---------- F1: orphan fix on VDS ---------- Write-Host "`n=== F1. orphan-fix snolla@stostayer on VDS ===" -ForegroundColor Cyan -$sa = (& bash -lc "pass show mssql-vds/sa-password" 2>$null | Select-Object -First 1) -if (-not $sa) { $sa = Read-Host "VDS sa password (pass show mssql-vds/sa-password)" } +# Get the VDS sa password from your normal terminal first: pass show mssql-vds/sa-password +# then paste it at the prompt (input hidden, not echoed). +$saSecure = Read-Host "Paste VDS sa password" -AsSecureString +$sa = [System.Net.NetworkCredential]::new('', $saSecure).Password +if (-not $sa) { Write-Error "No sa password provided."; return } $saConn = "Data Source=mssql.kzntsv.site,1433;Initial Catalog=master;User ID=sa;Password=$sa;TrustServerCertificate=True;Encrypt=True" $cn = New-Object System.Data.SqlClient.SqlConnection $saConn; $cn.Open() $c = $cn.CreateCommand() @@ -81,6 +84,7 @@ if (Test-Path "C:\sites\snolla") { Remove-Item "C:\sites\snolla" -Recurse -Force # ---------- M: local MSSQL teardown ---------- Write-Host "`n=== M. remove local MSSQL ===" -ForegroundColor Cyan +$ErrorActionPreference = 'Continue' # native docker stderr must not abort here docker stop mssql 2>$null | Out-Null docker rm mssql 2>$null | Out-Null docker volume rm mssql_mssql_data 2>$null | Out-Null