Ever need to audit remote computers to find out who is a local administrator or part of any other built in windows group? I recently ran into a need to do this. Found a few scripts out on the internet that do this, but I really wanted a function I could easily feed a list of computers from a text file or obtain from Get-ADComputers.

So, below is my take on the Get-NetLocalGroup function. This command basically uses a local ADSI connection to gather the required information and transforms it into powershell objects that can potentially be re-used down the pipeline.

A way you could use this function for example would be to  import a .csv file of computers you want to check and look who has administrator rights.


$Computers = Import-Csv C:\Computers.csv

Get-NetLocalGroup -Computername $Computers

Or say you need to check local admin group on all of your test computers (Assuming test is in the name, you could get creative with the search filter) then you could do the following:

Get-ADComputer -Filter {Name -like "*test*"} | Select-Object -ExpandProperty DNSHostname | Get-NetLocalGroup

Anyway, there’s lots of ways this function could potentially be used! Simply edit the alias section of the script if you need different pipeline input. Below is the code I’ve written for this purpose. If you have an existing PowerShell module library with functions for your help desk or junior admins, this might be a good addition to those modules.

The tools being developed on this blog are available on the PowerShell gallery here! This means to begin using the tool set, simply run the following command to install them.

Install-Module -Name ServerAdminCommon

If you have previously installed the toolset, you can update the tools using following command:

Update-Module -Name ServerAdminCommon

As with all of the modules on this blog, you can find this tool on my github page for the ServerAdminCommon tool set.


Disclaimer: All scripts and other powershell references on this blog are offered “as is” with no warranty. While these scripts are tested and working in my environment, it is recommended that you test these scripts in a test environment before using in your production environment.