getting list of administrators groups/individuals that belong to a server

I can rdp to the server, however I don't know the powershell command to get a list of users that belong to the local Administrators group. is it a wmi or active directory posting? Can you let me know what command to run ? Thank you ! ! !

Parents
No Data
Reply
  • You can use this code:

    $content = "Localhost"

    $Content | ForEach-Object {
    ([ADSI]"WinNT://$_/Administrators").Members() | Select-Object `
    @{n='Name';e={ $_.GetType().InvokeMember('Name', 'GetProperty', $Null, $_, $Null) }},
    @{n='ADSPath';e={ $_.GetType().InvokeMember('ADSPath', 'GetProperty', $Null, $_, $Null) }},
    @{n='Class';e={ $_.GetType().InvokeMember('class', 'GetProperty', $Null, $_, $Null) }}
    }

    Hope that helps.

Children
No Data