none
Export all users which has admin access from list of servers RRS feed

  • Question

  • Hi Jrv,

    I am using following script to export admin users from listed servers, but somehow the script is not listing the all users which has administration group assigned.  

    Can you please advise? 

    $servers= get-content 'C:\server.txt'
    $output = 'C:\admin_user_list.csv' 
    $results = @()
    
    foreach($server in $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


    • Edited by Rai01 Tuesday, July 3, 2018 3:55 AM
    • Moved by Bill_Stewart Monday, July 29, 2019 7:21 PM Abandoned
    Tuesday, July 3, 2018 3:55 AM

All replies