Validate MS SQL connection to PSU?

Product: PowerShell Universal
Version: 4.3.2

How do I validate the MS SQL connection to PSU? I’m patching the SQL Servers and after failover, I want to validate that PSU has reconnected to it’s MS SQL database.

Hi,

you could try something like this:

$ConnectionString = "<YOUR CONNECTION STRING HERE>"
$SqlConnection = New-Object Data.SqlClient.SqlConnection($ConnectionString)
try {
    $SqlConnection.Open()
    $SqlConnection.Dispose()
    $SqlConnection.Close()
    Write-Information "Successfully connected to SQL"
}
catch {
    Write-Error "Not connected to SQL"
}

Thank you, but I was looking for something specific to PSU, to indicate if PSU is connected to the SQL database. Basically, to confirm that PSU reconnected after the failover.

Hi,

create a database stored variable and try to call it, if it fails or empty, the connection isn’t established yet.

Thank you, I’ll try that!