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) <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,11 @@ Import-Module WebAdministration
|
|||||||
|
|
||||||
# ---------- F1: orphan fix on VDS ----------
|
# ---------- F1: orphan fix on VDS ----------
|
||||||
Write-Host "`n=== F1. orphan-fix snolla@stostayer on VDS ===" -ForegroundColor Cyan
|
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)
|
# Get the VDS sa password from your normal terminal first: pass show mssql-vds/sa-password
|
||||||
if (-not $sa) { $sa = Read-Host "VDS sa password (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"
|
$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()
|
$cn = New-Object System.Data.SqlClient.SqlConnection $saConn; $cn.Open()
|
||||||
$c = $cn.CreateCommand()
|
$c = $cn.CreateCommand()
|
||||||
@@ -81,6 +84,7 @@ if (Test-Path "C:\sites\snolla") { Remove-Item "C:\sites\snolla" -Recurse -Force
|
|||||||
|
|
||||||
# ---------- M: local MSSQL teardown ----------
|
# ---------- M: local MSSQL teardown ----------
|
||||||
Write-Host "`n=== M. remove local MSSQL ===" -ForegroundColor Cyan
|
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 stop mssql 2>$null | Out-Null
|
||||||
docker rm mssql 2>$null | Out-Null
|
docker rm mssql 2>$null | Out-Null
|
||||||
docker volume rm mssql_mssql_data 2>$null | Out-Null
|
docker volume rm mssql_mssql_data 2>$null | Out-Null
|
||||||
|
|||||||
Reference in New Issue
Block a user