Find PID with WMI

Hi everybody,

I´ve got a question, I try to find out which PID a User got.

We have several TS and sometimes the Logon process didn´t work, so I have to find out the PID of the User to kill the winlogon.exe (which is executed by SYSTEM).


I allready tried many thinks but nothing succeded ...


Many thanks !

No Data
  • i've only used this for logging out of RDP sessions, but it may help your situation

    # *** UNTESTED CODE ***
    $username1 = 'george.washington'
    $username2 = ''
    $users = "$username1|$username2"
    $servers = Get-Content 'c:\temp\servers.txt'
    foreach ($server in $servers) {
        # Get all users logged into a server
        $sessions = quser /SERVER:$server
        # Narrow to only sessions where specified users are logged in
        $subset = $sessions | Where-Object {$_ -match $users}
        # Log those users out
        foreach ($entry in $subset) {
            logoff ($entry | % {$_.split() | ? {$_})[1] /SERVER:$server

No Data