File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,10 @@ function Get-MSSQLLinkPasswords{
4343
4444 # Set local computername and get all SQL Server instances
4545 $ComputerName = $Env: computername
46- $SqlInstances = (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server' - Name InstalledInstances).InstalledInstances
47-
46+ $SqlInstances = (Get-ItemProperty - Path ' HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server' - Name InstalledInstances - ErrorAction SilentlyContinue).InstalledInstances
47+ if ($null -eq $SqlInstances ) {
48+ Write-Output " `n No instances were found on [$ComputerName ]`n "
49+ }
4850 $Results = New-Object " System.Data.DataTable"
4951 $Results.Columns.Add (" Instance" ) | Out-Null
5052 $Results.Columns.Add (" Linkserver" ) | Out-Null
@@ -73,7 +75,9 @@ function Get-MSSQLLinkPasswords{
7375
7476 Try {$Conn.Open ();}
7577 Catch {
76- Write-Error " Error creating DAC connection: $_ .Exception.Message"
78+ $errorMessage = " Error creating DAC connection:`n " + $_.Exception.Message
79+ $errorMessage = $errorMessage + " `n Attemped to connect using`n $ConnString `n "
80+ Write-Error - Category ConnectionError $errorMessage
7781 Continue
7882 }
7983 if ($Conn.State -eq " Open" ) {
You can’t perform that action at this time.
0 commit comments