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:
admins
admins
And what I am looking for is:
domain1\admins
domain2\admins
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 “https://powershell.org/2013/04/02/get-local-admin-group-members-in-a-new-old-way/”
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) "