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
Hi Zakaria,
I am also getting an issue, were you able to get a solution for it? If yes, please share
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
———— ———–
xxxxOMSBATCHxxxxOMSONLINE
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