Untitled

 avatar
unknown
plain_text
3 months ago
1.1 kB
6
Indexable
# Get the correct named pipe from the SQL Server instance
$pipe = "\\.\pipe\MICROSOFT##WID\tsql\query"

# Test if the pipe exists
if (-not (Test-Path "\\\\.\\pipe\\MICROSOFT##WID\\tsql\\query")) {
    Write-Host "Pipe not found. Listing available pipes..." -ForegroundColor Yellow
    Get-ChildItem "\\.\pipe\" | Where-Object { $_.Name -like "*sql*" -or $_.Name -like "*WID*" } | Select-Object Name
    exit
}

# Connection string using the pipe
$connStr = "Server=np:$pipe;Database=SUSDB;Integrated Security=SSPI;"

try {
    $conn = New-Object System.Data.SqlClient.SqlConnection($connStr)
    $conn.Open()
    Write-Host "Connected to WID" -ForegroundColor Green

    $cmd = $conn.CreateCommand()
    $cmd.CommandText = "SELECT PlugInID, FriendlyName FROM tbAuthorizationPlugin"

    $reader = $cmd.ExecuteReader()
    while ($reader.Read()) {
        $plugInId = $reader["PlugInID"]
        $friendlyName = $reader["FriendlyName"]
        Write-Host "PlugInID: $plugInId, FriendlyName: $friendlyName" -ForegroundColor Cyan
    }
    $reader.Close()
    $conn.Close()
} catch {
    Write-Host "Error: $_" -ForegroundColor Red
}
Editor is loading...
Leave a Comment