Windows Vista Forums

list users in a local group on a distant computer
  1. #1


    don5 Guest

    list users in a local group on a distant computer

    HI all



    any idea how to extract the users from a local group on a distant computer ?

    for example , i have a computer named "sha" and i want to know from my
    computer what are the users of his local "guest" group . and of course to
    import it to an excel file .

    tnx

      My System SpecsSystem Spec

  2. #2


    Shay Levi Guest

    Re: list users in a local group on a distant computer

    Hi don5,

    Try this (can't remember where I got it, I think from Brandon Shell)


    $name = "guest"
    $server = "sha"
    $group = [ADSI]("WinNT://$server/$name,group")
    $group.PSBase.InvokeGet("members")
    $members = $group.psbase.invoke("Members") | foreach {$_.GetType().InvokeMember("Name",
    'GetProperty', $null, $_, $null)}
    $members



    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > HI all
    >
    > any idea how to extract the users from a local group on a distant
    > computer ?
    >
    > for example , i have a computer named "sha" and i want to know from my
    > computer what are the users of his local "guest" group . and of course
    > to import it to an excel file .
    >
    > tnx
    >


      My System SpecsSystem Spec

  3. #3


    don5 Guest

    Re: list users in a local group on a distant computer

    Hi shay , tnx for the info

    basically it works , but i have one more Q .

    if inside the group i have another group , is there anyway i can somehow
    retrive also the users that belong to the group that is nested within this
    group ?

    "Shay Levi" wrote:

    > Hi don5,
    >
    > Try this (can't remember where I got it, I think from Brandon Shell)
    >
    >
    > $name = "guest"
    > $server = "sha"
    > $group = [ADSI]("WinNT://$server/$name,group")
    > $group.PSBase.InvokeGet("members")
    > $members = $group.psbase.invoke("Members") | foreach {$_.GetType().InvokeMember("Name",
    > 'GetProperty', $null, $_, $null)}
    > $members
    >
    >
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >
    >
    >

    > > HI all
    > >
    > > any idea how to extract the users from a local group on a distant
    > > computer ?
    > >
    > > for example , i have a computer named "sha" and i want to know from my
    > > computer what are the users of his local "guest" group . and of course
    > > to import it to an excel file .
    > >
    > > tnx
    > >
    >
    >
    >

      My System SpecsSystem Spec

  4. #4


    Brandon Shell [MVP] Guest

    Re: list users in a local group on a distant computer

    That wouldn't make alot of sense from a local perspective. AFAIK you can
    NOT nest local groups on a Machine. This would imply you mean Domain Groups
    that are added to Local Groups... you can do this, but it would required
    quering the AD for the information and it no longer a local query.

    An exception to this would be well-known groups, but those are calculated
    and do not really have member ship to begin with.

    Brandon Shell
    ---------------
    Blog: http://www.bsonposh.com/
    PSH Scripts Project: www.codeplex.com/psobject

    d> Hi shay , tnx for the info
    d>
    d> basically it works , but i have one more Q .
    d>
    d> if inside the group i have another group , is there anyway i can
    d> somehow retrive also the users that belong to the group that is
    d> nested within this group ?
    d>
    d> "Shay Levi" wrote:
    d>

    >> Hi don5,
    >>
    >> Try this (can't remember where I got it, I think from Brandon Shell)
    >>
    >> $name = "guest"
    >> $server = "sha"
    >> $group = [ADSI]("WinNT://$server/$name,group")
    >> $group.PSBase.InvokeGet("members")
    >> $members = $group.psbase.invoke("Members") | foreach
    >> {$_.GetType().InvokeMember("Name",
    >> 'GetProperty', $null, $_, $null)}
    >> $members
    >> -----
    >> Shay Levi
    >> $cript Fanatic
    >> http://scriptolog.blogspot.com
    >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

    >>> HI all
    >>>
    >>> any idea how to extract the users from a local group on a distant
    >>> computer ?
    >>>
    >>> for example , i have a computer named "sha" and i want to know from
    >>> my computer what are the users of his local "guest" group . and of
    >>> course to import it to an excel file .
    >>>
    >>> tnx
    >>>


      My System SpecsSystem Spec

  5. #5


    Shay Levi Guest

    Re: list users in a local group on a distant computer

    In addition to Brandon's answer, it would have to be recursive since nested
    groups are allowed on domain groups.

    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > Hi shay , tnx for the info
    >
    > basically it works , but i have one more Q .
    >
    > if inside the group i have another group , is there anyway i can
    > somehow retrive also the users that belong to the group that is nested
    > within this group ?
    >
    > "Shay Levi" wrote:
    >

    >> Hi don5,
    >>
    >> Try this (can't remember where I got it, I think from Brandon Shell)
    >>
    >> $name = "guest"
    >> $server = "sha"
    >> $group = [ADSI]("WinNT://$server/$name,group")
    >> $group.PSBase.InvokeGet("members")
    >> $members = $group.psbase.invoke("Members") | foreach
    >> {$_.GetType().InvokeMember("Name",
    >> 'GetProperty', $null, $_, $null)}
    >> $members
    >> -----
    >> Shay Levi
    >> $cript Fanatic
    >> http://scriptolog.blogspot.com
    >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

    >>> HI all
    >>>
    >>> any idea how to extract the users from a local group on a distant
    >>> computer ?
    >>>
    >>> for example , i have a computer named "sha" and i want to know from
    >>> my computer what are the users of his local "guest" group . and of
    >>> course to import it to an excel file .
    >>>
    >>> tnx
    >>>


      My System SpecsSystem Spec

  6. #6


    don5 Guest

    Re: list users in a local group on a distant computer

    ok guys , so lets say i have a domain group which i need to know its users
    and inside this group we have another group of users. all i want is to view
    all the users including the nested ones.

    how can i do this ?

    to retrive the users from a domain user i use the command :

    Get-QADGroupMember 'doman\group name' | Export-Csv -path c:\msh\tttt.csv

    so how do i fix the script in order to include all the users from a domain
    group nested inside this group ?

    "Shay Levi" wrote:

    > In addition to Brandon's answer, it would have to be recursive since nested
    > groups are allowed on domain groups.
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >
    >
    >

    > > Hi shay , tnx for the info
    > >
    > > basically it works , but i have one more Q .
    > >
    > > if inside the group i have another group , is there anyway i can
    > > somehow retrive also the users that belong to the group that is nested
    > > within this group ?
    > >
    > > "Shay Levi" wrote:
    > >

    > >> Hi don5,
    > >>
    > >> Try this (can't remember where I got it, I think from Brandon Shell)
    > >>
    > >> $name = "guest"
    > >> $server = "sha"
    > >> $group = [ADSI]("WinNT://$server/$name,group")
    > >> $group.PSBase.InvokeGet("members")
    > >> $members = $group.psbase.invoke("Members") | foreach
    > >> {$_.GetType().InvokeMember("Name",
    > >> 'GetProperty', $null, $_, $null)}
    > >> $members
    > >> -----
    > >> Shay Levi
    > >> $cript Fanatic
    > >> http://scriptolog.blogspot.com
    > >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    > >>> HI all
    > >>>
    > >>> any idea how to extract the users from a local group on a distant
    > >>> computer ?
    > >>>
    > >>> for example , i have a computer named "sha" and i want to know from
    > >>> my computer what are the users of his local "guest" group . and of
    > >>> course to import it to an excel file .
    > >>>
    > >>> tnx
    > >>>
    >
    >
    >

      My System SpecsSystem Spec

  7. #7


    Shay Levi Guest

    Re: list users in a local group on a distant computer



    Try:

    function get-members{
    param($groupName)

    Get-QADGroupMember -Identity $groupName | foreach {
    if($_.type -eq "user") {$_.name}
    elseif($_.type -eq "group") {$_.name; get-members -groupName $_.CanonicalName}

    }
    }

    get-members "domain\groupName'




    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > ok guys , so lets say i have a domain group which i need to know its
    > users and inside this group we have another group of users. all i want
    > is to view all the users including the nested ones.
    >
    > how can i do this ?
    >
    > to retrive the users from a domain user i use the command :
    >
    > Get-QADGroupMember 'doman\group name' | Export-Csv -path
    > c:\msh\tttt.csv
    >
    > so how do i fix the script in order to include all the users from a
    > domain group nested inside this group ?
    >
    > "Shay Levi" wrote:
    >

    >> In addition to Brandon's answer, it would have to be recursive since
    >> nested groups are allowed on domain groups.
    >>
    >> -----
    >> Shay Levi
    >> $cript Fanatic
    >> http://scriptolog.blogspot.com
    >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

    >>> Hi shay , tnx for the info
    >>>
    >>> basically it works , but i have one more Q .
    >>>
    >>> if inside the group i have another group , is there anyway i can
    >>> somehow retrive also the users that belong to the group that is
    >>> nested within this group ?
    >>>
    >>> "Shay Levi" wrote:
    >>>
    >>>> Hi don5,
    >>>>
    >>>> Try this (can't remember where I got it, I think from Brandon
    >>>> Shell)
    >>>>
    >>>> $name = "guest"
    >>>> $server = "sha"
    >>>> $group = [ADSI]("WinNT://$server/$name,group")
    >>>> $group.PSBase.InvokeGet("members")
    >>>> $members = $group.psbase.invoke("Members") | foreach
    >>>> {$_.GetType().InvokeMember("Name",
    >>>> 'GetProperty', $null, $_, $null)}
    >>>> $members
    >>>> -----
    >>>> Shay Levi
    >>>> $cript Fanatic
    >>>> http://scriptolog.blogspot.com
    >>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>>> HI all
    >>>>>
    >>>>> any idea how to extract the users from a local group on a distant
    >>>>> computer ?
    >>>>>
    >>>>> for example , i have a computer named "sha" and i want to know
    >>>>> from my computer what are the users of his local "guest" group .
    >>>>> and of course to import it to an excel file .
    >>>>>
    >>>>> tnx
    >>>>>


      My System SpecsSystem Spec

  8. #8


    don5 Guest

    Re: list users in a local group on a distant computer

    hi shai , i just dont want to be mistaken , where do i put the name of the
    group in your scrypt ?

    where do i put the name of the computer i want to retreive the list of users
    from the group ?

    tnx

    "Shay Levi" wrote:

    >
    >
    > Try:
    >
    > function get-members{
    > param($groupName)
    >
    > Get-QADGroupMember -Identity $groupName | foreach {
    > if($_.type -eq "user") {$_.name}
    > elseif($_.type -eq "group") {$_.name; get-members -groupName $_.CanonicalName}
    >
    > }
    > }
    >
    > get-members "domain\groupName'
    >
    >
    >
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >
    >
    >

    > > ok guys , so lets say i have a domain group which i need to know its
    > > users and inside this group we have another group of users. all i want
    > > is to view all the users including the nested ones.
    > >
    > > how can i do this ?
    > >
    > > to retrive the users from a domain user i use the command :
    > >
    > > Get-QADGroupMember 'doman\group name' | Export-Csv -path
    > > c:\msh\tttt.csv
    > >
    > > so how do i fix the script in order to include all the users from a
    > > domain group nested inside this group ?
    > >
    > > "Shay Levi" wrote:
    > >

    > >> In addition to Brandon's answer, it would have to be recursive since
    > >> nested groups are allowed on domain groups.
    > >>
    > >> -----
    > >> Shay Levi
    > >> $cript Fanatic
    > >> http://scriptolog.blogspot.com
    > >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    > >>> Hi shay , tnx for the info
    > >>>
    > >>> basically it works , but i have one more Q .
    > >>>
    > >>> if inside the group i have another group , is there anyway i can
    > >>> somehow retrive also the users that belong to the group that is
    > >>> nested within this group ?
    > >>>
    > >>> "Shay Levi" wrote:
    > >>>
    > >>>> Hi don5,
    > >>>>
    > >>>> Try this (can't remember where I got it, I think from Brandon
    > >>>> Shell)
    > >>>>
    > >>>> $name = "guest"
    > >>>> $server = "sha"
    > >>>> $group = [ADSI]("WinNT://$server/$name,group")
    > >>>> $group.PSBase.InvokeGet("members")
    > >>>> $members = $group.psbase.invoke("Members") | foreach
    > >>>> {$_.GetType().InvokeMember("Name",
    > >>>> 'GetProperty', $null, $_, $null)}
    > >>>> $members
    > >>>> -----
    > >>>> Shay Levi
    > >>>> $cript Fanatic
    > >>>> http://scriptolog.blogspot.com
    > >>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    > >>>>> HI all
    > >>>>>
    > >>>>> any idea how to extract the users from a local group on a distant
    > >>>>> computer ?
    > >>>>>
    > >>>>> for example , i have a computer named "sha" and i want to know
    > >>>>> from my computer what are the users of his local "guest" group .
    > >>>>> and of course to import it to an excel file .
    > >>>>>
    > >>>>> tnx
    > >>>>>
    >
    >
    >

      My System SpecsSystem Spec

  9. #9


    Shay Levi Guest

    Re: list users in a local group on a distant computer


    function get-members{
    param($groupName)

    Get-QADGroupMember -Identity $groupName | foreach {
    if($_.type -eq "user") {$_.name}
    elseif($_.type -eq "group") {$_.name; get-members -groupName $_.CanonicalName}

    }
    }

    There is no computer name, this script is for domain group, not local.
    If you have a group "RestrictedUsers" in a domain named "NWTraders"

    get-members "NWTraders\RestrictedUsers


    -----
    Shay Levi
    $cript Fanatic
    http://scriptolog.blogspot.com
    Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic



    > hi shai , i just dont want to be mistaken , where do i put the name
    > of the group in your scrypt ?
    >
    > where do i put the name of the computer i want to retreive the list of
    > users from the group ?
    >
    > tnx
    >
    > "Shay Levi" wrote:
    >

    >> Try:
    >>
    >> function get-members{
    >> param($groupName)
    >> Get-QADGroupMember -Identity $groupName | foreach {
    >> if($_.type -eq "user") {$_.name}
    >> elseif($_.type -eq "group") {$_.name; get-members -groupName
    >> $_.CanonicalName}
    >> }
    >> }
    >> get-members "domain\groupName'
    >>
    >> -----
    >> Shay Levi
    >> $cript Fanatic
    >> http://scriptolog.blogspot.com
    >> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic

    >>> ok guys , so lets say i have a domain group which i need to know
    >>> its users and inside this group we have another group of users. all
    >>> i want is to view all the users including the nested ones.
    >>>
    >>> how can i do this ?
    >>>
    >>> to retrive the users from a domain user i use the command :
    >>>
    >>> Get-QADGroupMember 'doman\group name' | Export-Csv -path
    >>> c:\msh\tttt.csv
    >>>
    >>> so how do i fix the script in order to include all the users from a
    >>> domain group nested inside this group ?
    >>>
    >>> "Shay Levi" wrote:
    >>>
    >>>> In addition to Brandon's answer, it would have to be recursive
    >>>> since nested groups are allowed on domain groups.
    >>>>
    >>>> -----
    >>>> Shay Levi
    >>>> $cript Fanatic
    >>>> http://scriptolog.blogspot.com
    >>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>>> Hi shay , tnx for the info
    >>>>>
    >>>>> basically it works , but i have one more Q .
    >>>>>
    >>>>> if inside the group i have another group , is there anyway i can
    >>>>> somehow retrive also the users that belong to the group that is
    >>>>> nested within this group ?
    >>>>>
    >>>>> "Shay Levi" wrote:
    >>>>>
    >>>>>> Hi don5,
    >>>>>>
    >>>>>> Try this (can't remember where I got it, I think from Brandon
    >>>>>> Shell)
    >>>>>>
    >>>>>> $name = "guest"
    >>>>>> $server = "sha"
    >>>>>> $group = [ADSI]("WinNT://$server/$name,group")
    >>>>>> $group.PSBase.InvokeGet("members")
    >>>>>> $members = $group.psbase.invoke("Members") | foreach
    >>>>>> {$_.GetType().InvokeMember("Name",
    >>>>>> 'GetProperty', $null, $_, $null)}
    >>>>>> $members
    >>>>>> -----
    >>>>>> Shay Levi
    >>>>>> $cript Fanatic
    >>>>>> http://scriptolog.blogspot.com
    >>>>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>>>>> HI all
    >>>>>>>
    >>>>>>> any idea how to extract the users from a local group on a
    >>>>>>> distant computer ?
    >>>>>>>
    >>>>>>> for example , i have a computer named "sha" and i want to know
    >>>>>>> from my computer what are the users of his local "guest" group .
    >>>>>>> and of course to import it to an excel file .
    >>>>>>>
    >>>>>>> tnx
    >>>>>>>


      My System SpecsSystem Spec

  10. #10


    Kirk Munro Guest

    Re: list users in a local group on a distant computer

    Beware that this can get into an endless loop when you have circular group
    membership (e.g group A contains group B contains group C contains group A).
    As long as you don't have circular group memberships, you should be ok.
    Otherwise you'll need to track which groups you have already retrieved
    members from using a hash table so that you don't get into that endless
    loop.

    --
    Kirk Munro
    Poshoholic
    http://poshoholic.com


    "Shay Levi" <no@xxxxxx> wrote in message
    news:8766a9441463d8ca108705ac44c2@xxxxxx

    >
    > function get-members{
    > param($groupName)
    >
    > Get-QADGroupMember -Identity $groupName | foreach {
    > if($_.type -eq "user") {$_.name}
    > elseif($_.type -eq "group") {$_.name; get-members -groupName
    > $_.CanonicalName}
    >
    > }
    > }
    >
    > There is no computer name, this script is for domain group, not local.
    > If you have a group "RestrictedUsers" in a domain named "NWTraders"
    >
    > get-members "NWTraders\RestrictedUsers
    >
    >
    > -----
    > Shay Levi
    > $cript Fanatic
    > http://scriptolog.blogspot.com
    > Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >
    >
    >

    >> hi shai , i just dont want to be mistaken , where do i put the name
    >> of the group in your scrypt ?
    >>
    >> where do i put the name of the computer i want to retreive the list of
    >> users from the group ?
    >>
    >> tnx
    >>
    >> "Shay Levi" wrote:
    >>

    >>> Try:
    >>>
    >>> function get-members{
    >>> param($groupName)
    >>> Get-QADGroupMember -Identity $groupName | foreach {
    >>> if($_.type -eq "user") {$_.name}
    >>> elseif($_.type -eq "group") {$_.name; get-members -groupName
    >>> $_.CanonicalName}
    >>> }
    >>> }
    >>> get-members "domain\groupName'
    >>>
    >>> -----
    >>> Shay Levi
    >>> $cript Fanatic
    >>> http://scriptolog.blogspot.com
    >>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>> ok guys , so lets say i have a domain group which i need to know
    >>>> its users and inside this group we have another group of users. all
    >>>> i want is to view all the users including the nested ones.
    >>>>
    >>>> how can i do this ?
    >>>>
    >>>> to retrive the users from a domain user i use the command :
    >>>>
    >>>> Get-QADGroupMember 'doman\group name' | Export-Csv -path
    >>>> c:\msh\tttt.csv
    >>>>
    >>>> so how do i fix the script in order to include all the users from a
    >>>> domain group nested inside this group ?
    >>>>
    >>>> "Shay Levi" wrote:
    >>>>
    >>>>> In addition to Brandon's answer, it would have to be recursive
    >>>>> since nested groups are allowed on domain groups.
    >>>>>
    >>>>> -----
    >>>>> Shay Levi
    >>>>> $cript Fanatic
    >>>>> http://scriptolog.blogspot.com
    >>>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>>>> Hi shay , tnx for the info
    >>>>>>
    >>>>>> basically it works , but i have one more Q .
    >>>>>>
    >>>>>> if inside the group i have another group , is there anyway i can
    >>>>>> somehow retrive also the users that belong to the group that is
    >>>>>> nested within this group ?
    >>>>>>
    >>>>>> "Shay Levi" wrote:
    >>>>>>
    >>>>>>> Hi don5,
    >>>>>>>
    >>>>>>> Try this (can't remember where I got it, I think from Brandon
    >>>>>>> Shell)
    >>>>>>>
    >>>>>>> $name = "guest"
    >>>>>>> $server = "sha"
    >>>>>>> $group = [ADSI]("WinNT://$server/$name,group")
    >>>>>>> $group.PSBase.InvokeGet("members")
    >>>>>>> $members = $group.psbase.invoke("Members") | foreach
    >>>>>>> {$_.GetType().InvokeMember("Name",
    >>>>>>> 'GetProperty', $null, $_, $null)}
    >>>>>>> $members
    >>>>>>> -----
    >>>>>>> Shay Levi
    >>>>>>> $cript Fanatic
    >>>>>>> http://scriptolog.blogspot.com
    >>>>>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
    >>>>>>>> HI all
    >>>>>>>>
    >>>>>>>> any idea how to extract the users from a local group on a
    >>>>>>>> distant computer ?
    >>>>>>>>
    >>>>>>>> for example , i have a computer named "sha" and i want to know
    >>>>>>>> from my computer what are the users of his local "guest" group .
    >>>>>>>> and of course to import it to an excel file .
    >>>>>>>>
    >>>>>>>> tnx
    >>>>>>>>
    >
    >


      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
list users in a local group on a distant computer problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
No users in Local Administrators Group am Vista security 1 22 Jan 2009
Re: List all Group Users in AD Shay Levy [MVP] PowerShell 0 02 Sep 2008
List all Group Users in AD Chris PowerShell 4 31 Aug 2008
Retrieve list of local users (non AD) Kryten PowerShell 4 29 Aug 2008
Add local machine users to local admin group via GPO Andrew .NET General 0 10 Jun 2008