Member of local administrators group from multiple servers in csv

Team,

I found this script:

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

invoke-command {
$members = net localgroup administrators | 
 where {$_ -AND $_ -notmatch "command completed successfully"} | 
 select -skip 4
New-Object PSObject -Property @{
 Computername = $env:COMPUTERNAME
 Group = "Administrators"
 Members=$members
 }
} -computer chi-fp01,chi-win8-01,chi-ex01 -HideComputerName | 
Select * -ExcludeProperty RunspaceID

---------

Question - Above computer name inserted manually, i got 1000+ servers copied in CSV, could i have command modified to call for a CSV file as input for -computer variable.

July 24th, 2015 4:29am

Try this one:

https://gallery.technet.microsoft.com/scriptcenter/Gather-Local-Group-0d0a85ad

Call it like this:

$servers = Get-Content servers.lst
$path    = "C:\Temp\serverlst_output.csv"

Get-RemoteGroupMembership -ComputerName $servers | Export-Csv -Path $path -NoTypeInformation

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 4:40am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics