Private/Add-SqlCertConnectivityHint.ps1
|
# ============================================================================= # Script : Private/Add-SqlCertConnectivityHint.ps1 # Author : Keith Ramsey # Created : 2026-05-16 # ============================================================================= # Change Log # ----------------------------------------------------------------------------- # 2026-05-16 Keith Ramsey Initial: when a failure message looks like a # WMI/RPC/WinRM/DCOM connectivity problem, append # a pointer to Docs/Fixing-WMI.md. Customer # service: tell them exactly where to go. # ============================================================================= # Decision Contract: honest hinting only - the pointer is appended ONLY when # the message matches a connectivity signature, never on unrelated errors # (no false advertising). Never throws. # ============================================================================= function Add-SqlCertConnectivityHint { [CmdletBinding()] [OutputType([string])] param([string] $Message) if (-not $Message) { return $Message } # Targeted signatures for "this is a transport/WMI/remoting problem". # Deliberately specific - generic "access is denied" is NOT matched, # because that is usually a permissions issue, not a WMI-off issue. $sig = @( 'WinRM', 'WS-?Man', 'RPC server is unavailable', '0x800706BA', 'CIM session', 'cannot connect to the destination', 'Connecting to remote server', 'WSManFault', 'DCOM', 'WMI .*not .*(running|available|enabled)', 'remote server .* failed' ) -join '|' if ($Message -match $sig) { return $Message + ' [SqlCertForge] This looks like a WMI / remote-connectivity issue. ' + 'Fix steps for every audience (manager, compliance, sysadmin, DBA), ' + 'including that dbatools needs the same: see Docs/Fixing-WMI.md. ' + 'No infrastructure available? Run this tool locally on the node - ' + 'the native path needs no WMI/WinRM.' } $Message } |