Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Local Administrators Group Listing

$
0
0

Thanks, Cyreli for giving me something to start with.  When I ran your code, I did not get any entries for the Administrators, which was all I needed.  A few tweaks & I got what I wanted.  (Very cool learning about how to tab the output). All I need to do is to read in a list of servers & I can produce a report for the corporate level.

-------------------------------------------------------------------

$list =@() 
$server="SERVER1","SERVER2"
$server | % {
                $server = $_
                $server
$GMembers = $Null
$LocalGroup = [ADSI]"WinNT://$server.<domain>.com/Administrators,group"
$GMembers = $LocalGroup.psbase.invoke("Members") 
$GMembers | ForEach { $us = $_.GetType().InvokeMember("Adspath",'GetProperty', $null, $_, $null)
$us = $us -replace "WinNT://",""
$list += new-object psobject -property @{Server=$server}
                                                "`t $us"}
}


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>