Afficher le groupe « Administrators ».

Posté le 16 mars 2010 par Christophe BLUTEAU

Permet d’afficher les membres du groupe « Administrators » sur une ordinateur distant.

$strComputer = Read-Host "Please enter the computer name"
 
$computer = [ADSI]("WinNT://" + $strComputer + ",computer")
$group = $computer.psbase.children.find("administrators")
 
Write-host ""
Write-host "Computer Name : "$computer.name
Write-Host "_____________________________________"
Write-host ""
Write-host "Group Name : "$Group.name
Write-Host "_____________________________________"
 
$domain = $group.path.split("/")[2]
$string1 = "WinNT://" + $domain + "/" + $strComputer + "/"
$string2 = $strComputer + "/"
$string3 = "WinNT://"
 
$members  = ($group.psbase.invoke(”Members”) | Foreach-Object {$_.GetType().InvokeMember(”Adspath”, ‘GetProperty’, $null, $_, $null)}) -replace ($string1,$string2) -replace ($string3,"") 
 
Write-host ""
Write-host "Members : "
Write-host ""
$members

Flux RSS des commentaires de cet article. TrackBack URI

Leave a Reply