![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Local Admin Group I am trying to find out the members of local administrators group on my machine. $Admin=[adsi]"WinNT://./Administrators,Group" $Admin.psbase.Invoke("Members") but the Invoke("Members") method returns a COM object , which I am not sure how to parse. PS > $Admin.psbase.Invoke("Members").Gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False __ComObject System.MarshalByRefObject |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Local Admin Group On Tue, 31 Oct 2006 09:17:06 -0800, XShell wrote: > I am trying to find out the members of local administrators group on my > machine. > > $Admin=[adsi]"WinNT://./Administrators,Group" > $Admin.psbase.Invoke("Members") > > but the Invoke("Members") method returns a COM object , which I am not sure > how to parse. > > PS > $Admin.psbase.Invoke("Members").Gettype() > > IsPublic IsSerial Name BaseType > -------- -------- ---- -------- > True False __ComObject > System.MarshalByRefObject I think there is a shortcoming in the .NET classes that handle WinNT. You would think you'd be on the right track. For example, using the LDAP provider a script like this works just fine. $Grp=[ADSI]"LDAP://CN=SAPIEN Authors,OU=SAPIEN,DC=MyCo,DC=local" #create an array object from current group members $grpMembers=@($grp.Member) #display current group membership Write-Host "There are currently" $grpMembers.Count "members in" $grp.Name foreach ($user in $grpMembers) {$user} I thought it would also work with the WinNT provider but I get the same results. I can get some information about the group but not the members either. -- Jeffery Hicks - www.ScriptingAnswers.com SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com Scripting books: www.SAPIENPress.com <http://www.sapienpress.com/> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Local Admin Group For WinNT provider use this script $objRoot = [ADSI]"WinNT://./Administrators,group" $objGrpMembers = @($objRoot.psbase.Invoke("Members")) Write-Host "There are currently" $objGrpMembers.Count "members in" $objRoot.Name $objGrpMembers |Format-Table -HideTableHeader @{e={""};w=6}, @{e={$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)};w=21}, @{e={$_.GetType().InvokeMember("Class", 'GetProperty', $null, $_, $null)};w=8}, @{e={$_.GetType().InvokeMember("AdsPath", 'GetProperty', $null, $_, $null)};w=50} AlKos "Jeffery Hicks" <"jhicks[at]SAPIEN.com" wrote: > On Tue, 31 Oct 2006 09:17:06 -0800, XShell wrote: > > > I am trying to find out the members of local administrators group on my > > machine. > > > > $Admin=[adsi]"WinNT://./Administrators,Group" > > $Admin.psbase.Invoke("Members") > > > > but the Invoke("Members") method returns a COM object , which I am not sure > > how to parse. > > > > PS > $Admin.psbase.Invoke("Members").Gettype() > > > > IsPublic IsSerial Name BaseType > > -------- -------- ---- -------- > > True False __ComObject > > System.MarshalByRefObject > > I think there is a shortcoming in the .NET classes that handle WinNT. You > would think you'd be on the right track. For example, using the LDAP > provider a script like this works just fine. > > $Grp=[ADSI]"LDAP://CN=SAPIEN Authors,OU=SAPIEN,DC=MyCo,DC=local" > > #create an array object from current group members > $grpMembers=@($grp.Member) > > #display current group membership > Write-Host "There are currently" $grpMembers.Count "members in" $grp.Name > foreach ($user in $grpMembers) {$user} > > I thought it would also work with the WinNT provider but I get the same > results. I can get some information about the group but not the members > either. > > -- > Jeffery Hicks - www.ScriptingAnswers.com > SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com > Scripting books: www.SAPIENPress.com <http://www.sapienpress.com/> > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| delete user from the local admin group | PowerShell | |||
| Add local machine users to local admin group via GPO | .NET General | |||
| Add domain admin to local admin group | Vista General | |||
| In local Admin group but still Acess Denied. | Vista account administration | |||
| local admin group members? | PowerShell | |||