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