Skript, mis kuvab kasutajad ja grupid: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
== Pikkem varjant == | == Pikkem varjant == | ||
Line 39: | Line 38: | ||
$groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)} | $groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)} | ||
$_ | Select-Object @{n='Kasutajad';e={$_.Name}},@{n=' | $_ | Select-Object @{n='Kasutajad';e={$_.Name}},@{n='Grupid';e={$groups -join ' & '} | ||
} | } | ||
} | } |
Revision as of 10:42, 27 May 2011
Pikkem varjant
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
}
}
}
}
}
== Lühem varjant ==
# Skript väljastab kasutajad ja gruppid kuhu nad kuuluvad.
$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 ' & '}
}
}