This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

How to get the local Administrators of one or many computers remotely with PowerShell.

This is a request that was made by someone a few months ago. It’s been a while so I apologize for not remembering who requested it. We’re using the Win32_GroupUser class to get the local administrators of a computer or many computers remotely. The function is modular enough to give you the ability to view the results in the console, export to a CSV, or a text file if you really wanted to I guess.

If you know of an easier method of doing this please let me know.

Code Download: https://github.com/signalwarrant/Powershell/blob/master/Get-LocalAdmins.ps1


  1. Veer | | Reply

    Hi Zakaria,

    I am also getting an issue, were you able to get a solution for it? If yes, please share

  2. Zakaria Hj Siwan | | Reply

    Thanks for your brilliant scripts.. u save my day Sir..

    However, when I tried to run more than 1 server the scripts having error

    PS C:\Temp> Get-LocalAdmins -Computers xxxxOMSBATCH

    ComputerName LocalAdmins
    ———— ———–
    xxxxOMSBATCH xxxxOMSBATCH\tmladm…

    PS C:\Temp> Get-LocalAdmins -Computers xxxxOMSBATCH,xxxxOMSONLINE
    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At C:\Temp\localadmin.ps1:39 char:19
    + … $admins = Get-WmiObject -Class win32_groupuser -ComputerName $compu …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    ComputerName LocalAdmins
    ———— ———–

    PS C:\Temp>

    Any idea how to proceed with the scripts with more than 1 server ? At your tutorial, seem like no issue at all..

    Thanks in advance.

    Zakaria Hj Siwan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.