Skript, mis kuvab kasutajad ja grupid

From ICO wiki
Revision as of 12:25, 24 May 2011 by Iambos (talk | contribs) (Created page with ''''Skript kuvab kõik kasutajad ja grupid kuhu kasutajad kuuluvad.''' <source lang="powershell"> $computer = [ADSI]("WinNT://arvuti nimi,computer") $Users = $computer.psbase.chil…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Skript kuvab kõik kasutajad ja grupid kuhu kasutajad kuuluvad.

$computer = [ADSI]("WinNT://arvuti nimi,computer")
$Users = $computer.psbase.children |where{$_.psbase.schemaclassname -eq "User"}
$grupid = $computer.psbase.children |where{$_.psbase.schemaclassname -eq "Group"}

foreach ($member in $Users.psbase.syncroot) 
{ 
    write-host $member.Name
    
   foreach ($grupp in $grupid) 
    { 
        $olemas = $grupp.psbase.invoke("Members") | foreach {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
        if($olemas)
        { 
            foreach($x in $olemas)
            {
                if($x -eq $member.Name)
                {
                    Write-Host "-------"$grupp.Name
                }
            }
        }
    }
}