# NAM LDAP cutover, QA vq03/vq04 — Phase 0 preflight + backups (read-only except the backup folder). Secret values are never printed. $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue' $ts = Get-Date -Format 'yyyyMMddTHHmmss' $bk = "E:\ApiInstall\_ldapcut-$ts"; New-Item -ItemType Directory -Force $bk | Out-Null & icacls.exe $bk /inheritance:r /grant:r 'SYSTEM:(OI)(CI)F' 'BUILTIN\Administrators:(OI)(CI)F' | Out-Null "box $env:COMPUTERNAME backup dir $bk" foreach ($h in 'uswap-vdc-nam1.nam.zimmer.com','uswap-vdc-nam2.nam.zimmer.com') { foreach ($p in 636,389) { $c = New-Object Net.Sockets.TcpClient; $ok = $c.ConnectAsync($h,$p).Wait(4000); $c.Dispose(); "reach $h`:$p $ok" } } $root = @(Get-ChildItem Cert:\LocalMachine\Root | Where-Object { $_.Subject -like '*zimmer-rootca*' }) "zimmer-rootca in LocalMachine\Root: $($root.Count) $(($root | % { $_.Thumbprint + ' exp ' + $_.NotAfter.ToString('yyyy-MM-dd') }) -join '; ')" foreach ($h in 'uswap-vdc-nam1.nam.zimmer.com','uswap-vdc-nam2.nam.zimmer.com') { try { $t = New-Object Net.Sockets.TcpClient($h,636); $script:err = $null $s = New-Object Net.Security.SslStream($t.GetStream(), $false, { param($a,$b,$c,$e) $script:err = $e; $true }) $s.AuthenticateAsClient($h); "tls $h policyErrors=$script:err proto=$($s.SslProtocol)"; $s.Dispose(); $t.Dispose() } catch { "tls $h FAILED $($_.Exception.Message)" } } $svcs = Get-CimInstance Win32_Service | Where-Object { $_.PathName -match 'ApiInstall\\(HistorianGateway|MxAccessGateway|MxGateway|OtOpcUa|ScadaBridge)' -or $_.Name -match 'HistorianGateway|MxGateway|MxAccess|OtOpcUa|ScadaBridge' } $show = '(?i)ENVIRONMENT$|DisableLogin|AllowOutside|Cookie|__Ldap__(Enabled|DevStub|Server|Port|Transport|AllowInsecure|SearchBase|ServiceAccountDn|UserNameAttribute|DisplayNameAttribute|GroupAttribute|BindMode|FallbackServers|UseTls|RequiredGroup)|GroupToRole|Secrets__.*(SqlitePath|Source|FilePath|EnvVarName|Provider|Enabled|Schema|Table|Mode)$|RequiredGroup|Thumbprint|Redundancy|PeerApplicationUris|ApplicationUri|^ScadaBridge__Node|Cluster__Roles|Runner|ASPNETCORE_URLS' foreach ($s in $svcs) { "== service $($s.Name) state=$($s.State) path=$($s.PathName)" & reg.exe export "HKLM\SYSTEM\CurrentControlSet\Services\$($s.Name)" "$bk\reg-$($s.Name).reg" /y | Out-Null $k = "HKLM:\SYSTEM\CurrentControlSet\Services\$($s.Name)" $p = Get-ItemProperty "$k\Parameters" -ErrorAction SilentlyContinue if ($p.AppDirectory) { " nssm AppDirectory=$($p.AppDirectory) Application=$($p.Application)" } $lines = @((Get-ItemProperty $k -ErrorAction SilentlyContinue).Environment | % { "[svc] $_" }) + @($p.AppEnvironmentExtra | % { "[nssm] $_" }) | Where-Object { $_ } foreach ($l in $lines) { $tag, $l = $l -split " ", 2; $i = $l.IndexOf('='); if ($i -lt 1) { continue }; $n = $l.Substring(0,$i) if ($n -match $show -and $l -notmatch '(?i)password|key=|pepper|secret=') { " $tag env $l" } else { " $tag env $n=" } } } foreach ($p in 'HistorianGateway\app\appsettings*.json','MxAccessGateway\app\appsettings*.json','OtOpcUa\app\appsettings*.json','ScadaBridge\app\appsettings*.json') { foreach ($f in Get-ChildItem "E:\ApiInstall\$p" -ErrorAction SilentlyContinue) { $d = "$bk\" + ($f.FullName.Substring(15) -replace '\\','_'); Copy-Item $f.FullName $d; "copied $($f.FullName) sha256 $((Get-FileHash $d).Hash.Substring(0,16))" } } foreach ($d in 'HistorianGateway','MxAccessGateway','OtOpcUa','ScadaBridge') { foreach ($dll in Get-ChildItem "E:\ApiInstall\$d\app" -Filter '*.dll' -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^(ZB\.MOM\.WW\.(HistorianGateway\.Server|OtOpcUa\.Host|ScadaBridge\.Host)|MxGateway\.Server)\.dll$' }) { "ver $d $($dll.Name) $($dll.VersionInfo.ProductVersion)" } } Get-ChildItem 'E:\ApiInstall' -Directory | % { "dir $($_.Name)" } Get-ChildItem 'E:\ApiInstall\_tools' -Recurse -Filter '*.exe' -ErrorAction SilentlyContinue | % { "tool $($_.FullName) $($_.VersionInfo.ProductVersion)" } foreach ($u in 'http://127.0.0.1:9000/health/active','http://127.0.0.1:8085/health/active','http://127.0.0.1:8084/health/active') { try { $r = Invoke-WebRequest -UseBasicParsing $u -TimeoutSec 5; "$u $($r.StatusCode) $($r.Content)" } catch { "$u $($_.Exception.Response.StatusCode.value__)" } } "PREFLIGHT DONE $bk"