Skript, mis kuvab kasutajad ja grupid: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 27: | Line 27: | ||
} | } | ||
</source> | |||
== Lühem varjant == | == Lühem varjant == | ||
<source lang="powershell"> | |||
$computer = [ADSI]"WinNT://$env:COMPUTERNAME" | $computer = [ADSI]"WinNT://$env:COMPUTERNAME" |
Latest revision as of 10:44, 27 May 2011
Skript kuvab kõik kasutajad ja grupid kuhu kasutajad kuuluvad.
Pikkem varjant
$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
}
}
}
}
}
Lühem varjant
$computer = [ADSI]"WinNT://$env:COMPUTERNAME"
$computer.Children | where {$_.SchemaClassName -eq 'user'} | Foreach-Object {
$groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
$_ | Select-Object @{n='Kasutajad';e={$_.Name}},@{n='Grupid';e={$groups -join ' & '}
}
}