tlberlus
Goto Top

Powershell User-Workstation

Hallo Kollegen,

habe ich eine Möglichkeit, herauszufinden, auf welcher Workstation sich ein User momentan angemeldet hat ohne das ich das Eventlog aller PC´s der Domäne durchsuche?

P.S. Den User fragen zählt nicht.

Grüße,

Tiberius

Content-Key: 310176

Url: https://administrator.de/contentid/310176

Printed on: May 10, 2024 at 08:05 o'clock

Mitglied: 129813
129813 Jul 18, 2016 at 11:50:18 (UTC)
Goto Top
Itterate over all online workstations and query the loggedon user via wmi
gwmi Win32_ComputerSystem -ComputerName $computer -EA SilentlyContinue | select -Expand Username
Regards
Member: Cloudy
Cloudy Jul 18, 2016 updated at 13:16:33 (UTC)
Goto Top
Bei $searchusername schreibst du den Betreffenden Benutzernamen und bei $SearchBase deine Domäne rein.
$searchusername = "USER"  
$SearchBase = "DC=contoso,DC=com";  
$credential = Get-Credential;
$computers = $(Get-ADComputer -Filter * -SearchBase $SearchBase -Credential $credential).DNSHostName;

ForEach ($computer in $computers) {
    if ($(Get-WmiObject Win32_ComputerSystem -Credential $credential -ComputerName $computer -EA SilentlyContinue).Username -eq "$searchusername")  
    {
        Write-Output "User is on $computer"  
    } else {
        Write-Debug "User is not on $computer"  
    }
}

Alternativ ginge auch ein logon Script, das dir den Hostname in ein ActiveDirectory Atribut schreibt...