A forum user asked for assistance with a PowerShell script that would read a list of servers from a text file and then either show the list of users in the local administrator groups on each server.
The script below, Get-LocalMembers, takes things a bit further. While it will default to the local administrators group, you can supply any number of groups to the script. It even supports wildcards! By default, the results are displayed on the console, but can also export the results as a .csv file.
The script takes 2 parameters (both optional):
A list of computers to query. The list may be provided as a parameter to the script, or read from a text file. Default: localhost
A list of local groups to query on each of the computers. Wildcards are support (see examples below). Default: Administrators
Retrieves the members of the default group (Administrators) on the default computer(localhost).
Get-LocalMembers -Computers (Get-Content -Path "c:\temp\computers.txt")
Will retrieve the members of the Administrators group on all the computers in the file computers.txt.
Get-LocalMembers -groups 'Remote*','Admin*'
Will retrieve the members of the Administrators, Remote Desktop Users and Remote Management Users groups on localhost.
Get-LocalMembers | Export-Csv -Path "c:\reports\GroupMembers.csv" -NoTypeInformation
Retrieves the members of the default group (Administrators) on the default computer(localhost) and exports them to the specified .csv file.
Sam Jacobs is the Director of Technology at Newtek Technology Systems (formerly IPM), the longest standing Citrix Platinum Partner on the East Coast. With more than 30 years of IT consulting, Sam is a NetScaler and StoreFront customizations and integrations industry expert. He holds Microsoft and Citrix certifications, and is the editor of TechDevCorner.com, a technical resource blog for IT professionals. He is one of the top Citrix support Forum contributors, and has earned industry praise for the tools he has developed to make NetScaler, StoreFront and Web Interface easier to manage for administrators and more intuitive for end users. Sam became a Citrix Technology Professional (CTP) in 2015, and can be reached at: firstname.lastname@example.org or on Twitter at: @WIGuru.