Windows Vista Forums

local admin group members?
  1. #1


    VB Guest

    local admin group members?

    What is the equivalent in PS of the bellow code (cannot find .members in
    PS):





    strComputer = "atl-fs-01"

    Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")

    For Each objUser In colGroups.Members
    Wscript.Echo objUser.Name
    Next



    Thanks,

    VB



      My System SpecsSystem Spec

  2. #2


    AlKos Guest

    RE: local admin group members?

    This script you write all groups and their members

    $objRoot = [ADSI]"WinNT://."
    If ($objRoot.Name -eq $null)
    {
    Write-Host "Computer wasn't connected"
    }
    else
    {
    If ($objRoot.Name -eq "."){$strComputerName = (get-content
    env:COMPUTERNAME)}else {$strComputerName = $objRoot.Name}
    "Local accounts on computer $strComputerName`n"
    "Groups:"
    Foreach ($objDirEntry in $objRoot.psbase.get_Children())
    {
    if ("Group" -eq $objDirEntry.psbase.Get_SchemaClassName())
    {
    $objDirEntry.Name
    if (@($objDirEntry.psbase.Invoke("Members")).Count -eq 0)
    {
    " This group hasn't an members.`n"
    }
    else
    {
    " Members:"
    $objDirEntry.psbase.Invoke("Members") |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


    "VB" wrote:

    > What is the equivalent in PS of the bellow code (cannot find .members in
    > PS):
    >
    >
    >
    > strComputer = "atl-fs-01"
    >
    > Set colGroups = GetObject("WinNT://" & strComputer & "/Administrators")
    >
    > For Each objUser In colGroups.Members
    > Wscript.Echo objUser.Name
    > Next
    >
    >
    >
    > Thanks,
    >
    > VB
    >
    >
    >


      My System SpecsSystem Spec

local admin group members? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Domain Admins to Local admin group JohnB Server General 12 04 Oct 2009
Why this script list a local administrator group members? Todd Sun PowerShell 1 04 Mar 2009
Add local machine users to local admin group via GPO Andrew .NET General 0 10 Jun 2008
Add domain admin to local admin group BigHaig Vista General 2 07 Jul 2007
Local Admin Group XShell PowerShell 2 05 Nov 2006