PowerShell: Who is logged onto SQL Servers via RDP?

# Remote desktop users - who is RDPed into SQL Servers?
 
$AllComputersList |%{ 
    $ComputerName = $_ ; 
    write-host -ForegroundColor Cyan $ComputerName
    #(qwinsta /SERVER:$ComputerName)
     
    $RDPUser = (quser /SERVER:$ComputerName 2>$null )  # Don't show us any DOS errors.
    if (!$RDPUser) {
        return # continue
    }
    $RDPUser
}

Comments are closed.

Post Navigation