Windows: angemeldete Benutzerer auslesen: Unterschied zwischen den Versionen

Aus MyWiki
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>
im meinem Fall hole ich mir den Benutzernamen aus der Umgebungsvariable GIT_AUTHOR_NAME die per GPO gesetzt wird.<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")
    $computers = @("pc01","pc02")
  foreach ($computer in $computers)
    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 {
                $noOutput = New-PSDrive HKU Registry HKEY_USERS
            $users  = "";
                Set-Location HKU:
            $noOutput = New-PSDrive HKU Registry HKEY_USERS
                Get-ChildItem -Path HKU: | where {$_.Name.Length -gt 25 -and $_.Name -notlike "*Classes"} | % {$Path = $_.Name + "\Environment"; Get-ItemProperty -Path $Path | select GIT_AUTHOR_NAME | where GIT_AUTHOR_NAME -ne $ull}
            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