Get Local admins with domain

Welcome Forums General PowerShell Q&A Get Local admins with domain

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 6 months ago.

  • Author
  • #58172

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    Hi fellow Poshers,

    I have been looking all over the InterTubes for a way to adjust this code to return the domain for the members within the local admins group.

    $group =[ADSI]"WinNT://$computer/Administrators" 
    $members = @($group.psbase.Invoke('Members'))
    $LocalAdmins = $members | ForEach-Object {$_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null) } 

    Running the above code will give me a list like below:

    And what I am looking for is:

    Due to restrictions I don't have access to wsman on windows 2008 server and cannot invoke-command, otherwise I would use the method mentioned in article ""

    Additionally if any of you deep web ninjas are feeling particularly randy, I'd love to understand what is going on in this command "$_.GetType().InvokeMember('Name', 'GetProperty', $null, $_, $null) "

  • #58187

    Topics: 0
    Replies: 44
    Points: 43
    Rank: Member

    Take a look at this blog post from Jeff Hicks. He uses the ADSI method to get the local admin group members and display their domain name:

The topic ‘Get Local admins with domain’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort