77282
Mar 13, 2018, updated at 09:43:49 (UTC)
39640
4
0
Powershell abfragen wer gerade an PC angemeldet ist
Hallo, gibt es einen PowerShell Befehl zum abfragen wer gerade an einem bestimmten PC angemeldet ist?
Grüße
Grüße
Please also mark the comments that contributed to the solution of the article
Content-Key: 367892
Url: https://administrator.de/contentid/367892
Printed on: April 23, 2024 at 22:04 o'clock
4 Comments
Latest comment
Hatten wir hier zwar schon 1000 und einmal ...
Gibt es verschiedene Varianten
Oder auch
Grüße Uwe
Gibt es verschiedene Varianten
Function Get-LoggedOnUsers {
Param(
[Parameter(Mandatory = $True,Position = 0,ValueFromPipeline = $True)][string[]]$computers
)
Process {
foreach($comp in $computers){
gwmi win32_process -computer $comp -Filter "Name = 'explorer.exe'" | %{
[pscustomobject] @{"Computer"=$comp;"Domain"=($_.GetOwner()).Domain;"User"=($_.GetOwner()).User}
}
}
}
}
$computer = 'ComputerXYZ'
gwmi win32_LogonSession -Computer $computer -Filter 'LogonType=2 or LogonType=10' | %{
gwmi -ComputerName $computer -Query "Associators of {Win32_LogonSession.LogonId=$($_.LogonId)} Where AssocClass=Win32_LoggedOnUser Role=Dependent" | select -Expand Name
}