Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Import list of servers, export their member of groups

$
0
0

I have a list of servers in a text file, and I would like a script to say if they are in a particular group (I have several similarlay named groups - and need to know when the server ISN'T in any of these)

I've found a script that would import the server list and tell me if it's in an Admin group - can I just duplicate the lines where the admin account is and retype with each of my groups?

$servers= get-content 'c:\input\test.txt'$output='c:\output\test.csv' $results= @()foreach($serverin$servers)
{
$admins= @()
$group=[ADSI]"WinNT://$server/Administrators"$members= @($group.psbase.Invoke("Members"))$members | foreach {$obj= new-object psobject -Property @{ Server =$Server Admin =$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) }$admins+=$obj } $results+=$admins }$results| Export-csv $Output-NoTypeInformation


Viewing all articles
Browse latest Browse all 15028

Trending Articles



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