Windows: angemeldete Benutzerer auslesen: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
Man kann die angemeldeten Benutzer anhand der Registry auslesen.<br> | Man kann die angemeldeten Benutzer anhand der Registry auslesen.<br> | ||
Von allen Benutzern die angemeldet sind, wird unter HKEY_USERS die Registry mit der SID geladen. <br> | Von allen Benutzern die angemeldet sind, wird unter HKEY_USERS die Registry mit der SID geladen. <br> | ||
Unterdem Pfad ".\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}" steht der Username <br> | |||
die GUID war auf allen Rechnern gleich, egal ob Windows 10 oder Windows 7 | |||
$computers = @("pc01","pc02") | |||
foreach ($computer in $computers) | |||
{ | |||
write-host "gehe zu $computer" -ForegroundColor yellow | write-host "gehe zu $computer" -ForegroundColor yellow | ||
invoke-command -ComputerName "$computer" -ScriptBlock { | invoke-command -ComputerName "$computer" -ScriptBlock { | ||
$users = ""; | |||
$noOutput = New-PSDrive HKU Registry HKEY_USERS | |||
Set-Location HKU: | |||
$items = Get-ChildItem -Path HKU: | where {$_.Name.Length -gt 25 -and $_.Name -notlike "*Classes"} | |||
foreach ($item in $items) { | |||
$Path = $item.Name + '\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}'; | |||
if (Test-Path -Path $Path) { | |||
$username = Get-ItemProperty -Path $Path | |||
if ($username.Username -ne $null) {Write-Host $username.Username} | |||
} | |||
} | |||
} | } | ||
} | } | ||
Aktuelle Version vom 26. Februar 2016, 13:39 Uhr
Man kann die angemeldeten Benutzer anhand der Registry auslesen.
Von allen Benutzern die angemeldet sind, wird unter HKEY_USERS die Registry mit der SID geladen.
Unterdem Pfad ".\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}" steht der Username
die GUID war auf allen Rechnern gleich, egal ob Windows 10 oder Windows 7
$computers = @("pc01","pc02")
foreach ($computer in $computers)
{
write-host "gehe zu $computer" -ForegroundColor yellow
invoke-command -ComputerName "$computer" -ScriptBlock {
$users = "";
$noOutput = New-PSDrive HKU Registry HKEY_USERS
Set-Location HKU:
$items = Get-ChildItem -Path HKU: | where {$_.Name.Length -gt 25 -and $_.Name -notlike "*Classes"}
foreach ($item in $items) {
$Path = $item.Name + '\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}';
if (Test-Path -Path $Path) {
$username = Get-ItemProperty -Path $Path
if ($username.Username -ne $null) {Write-Host $username.Username}
}
}
}
}
Alternativ kann man folgendes versuchen, aber das hat nicht auf allen Rechnern sauber funktioniert
Get-WmiObject Win32_ComputerSystem -ComputerName <COMPUTERNAME> | Select-Object Name,UserName