+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
How do you do....it? Thread, Display count of computers in an AD group? in Technical; Hi, All i want it to show the number of computer objects in a group. It will take to long ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447

    Display count of computers in an AD group?

    Hi,

    All i want it to show the number of computer objects in a group. It will take to long and it wont be accurate to manually count them. The group will not contain users.

    Does anyone know how to do this please? I cant find much on Google.

    Thanks

  2. #2

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Can you not do an advanced find in Ad.

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    I had a play around but i couldn't see how. Maybe i missed something?

  4. #4

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    I'm not a pc (on my phone in Kuala Lumpur airport!)

    But it's something like this.

    Ad - find - select computers from.drop down menu - click advanced - then.select member of - group name.

    It's possible with users for sure but not 100% if you can with pcs

  5. #5

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    You dont have that option. Please see the attached.

    Thanks
    Attached Images Attached Images

  6. #6

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Try looking from the custom query (or whatever it is called) at the bottom of the computers drop down. Might be able to do it there. I'm stabbing in the dark without access to a pc!!

  7. #7

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Also csvde may be able to export you a list to csv.

    Also try a trail of Admanger plus. It might do the trick.

  8. #8

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    Nothing in custom. Will have a look at csvde, its not really what i want. Also with AD manager plus long term it wont be ideal really.

    Thanks anyway

  9. #9

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    This is for users - you might be able to adapt to show computers in a group

    csvde -f C:\Get-Group\report.csv -r
    "(&(objectCategory=person)(objectClass=user)(whenCrea ted>=20071008000000.0Z))" -l userPrincipalName,sAMAccountName -s saturn.lcbt.co.uk
    You could also query AD from a PHP page or similar. Have a desktop now just doing a bit of digging.

  10. Thanks to glennda from:

    FN-GM (31st January 2012)

  11. #10


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,878
    Thank Post
    226
    Thanked 2,669 Times in 1,968 Posts
    Rep Power
    786
    PowerShell?

    Code:
    if(!(Get-PSSnapin | Where {$_.name -eq "Quest.ActiveRoles.ADManagement"})) { 
        Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction 0 | Out-Null
    }
    
    @(Get-QADGroupMember "Example Group" -Enabled).count
    
    
    # or
    
    
    Get-QADGroup "Example Group" -SizeLimit 0 | Select-Object Name,@{n='MemberCount';e={ (Get-QADGroupMember $_ | Measure-Object).Count}}

  12. Thanks to Arthur from:

    FN-GM (31st January 2012)

  13. #11

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Powershell will work but i havn't used that much!

    With regards to PHP script there is one below which could be modified to suit Link

    PHP Code:
    <?php

    $user 
    'bob';
    $password 'zhlob';
    $host 'myldap';
    $domain 'mydomain.ex';
    $basedn 'dc=mydomain,dc=ex';
    $group 'SomeGroup';

    $ad ldap_connect("ldap://{$host}.{$domain}") or die('Could not connect to LDAP server.');
    ldap_set_option($adLDAP_OPT_PROTOCOL_VERSION3);
    ldap_set_option($adLDAP_OPT_REFERRALS0);
    @
    ldap_bind($ad"{$user}@{$domain}"$password) or die('Could not bind to AD.');
    $userdn getDN($ad$user$basedn);
    if (
    checkGroupEx($ad$userdngetDN($ad$group$basedn))) {
    //if (checkGroup($ad, $userdn, getDN($ad, $group, $basedn))) {
        
    echo "You're authorized as ".getCN($userdn);
    } else {
        echo 
    'Authorization failed';
    }
    ldap_unbind($ad);

    /*
    * This function searchs in LDAP tree ($ad -LDAP link identifier)
    * entry specified by samaccountname and returns its DN or epmty
    * string on failure.
    */
    function getDN($ad$samaccountname$basedn) {
        
    $attributes = array('dn');
        
    $result ldap_search($ad$basedn,
            
    "(samaccountname={$samaccountname})"$attributes);
        if (
    $result === FALSE) { return ''; }
        
    $entries ldap_get_entries($ad$result);
        if (
    $entries['count']>0) { return $entries[0]['dn']; }
        else { return 
    ''; };
    }

    /*
    * This function retrieves and returns CN from given DN
    */
    function getCN($dn) {
        
    preg_match('/[^,]*/'$dn$matchsPREG_OFFSET_CAPTURE3);
        return 
    $matchs[0][0];
    }

    /*
    * This function checks group membership of the user, searching only
    * in specified group (not recursively).
    */
    function checkGroup($ad$userdn$groupdn) {
        
    $attributes = array('members');
        
    $result ldap_read($ad$userdn"(memberof={$groupdn})"$attributes);
        if (
    $result === FALSE) { return FALSE; };
        
    $entries ldap_get_entries($ad$result);
        return (
    $entries['count'] > 0);
    }

    /*
    * This function checks group membership of the user, searching
    * in specified group and groups which is its members (recursively).
    */
    function checkGroupEx($ad$userdn$groupdn) {
        
    $attributes = array('memberof');
        
    $result ldap_read($ad$userdn'(objectclass=*)'$attributes);
        if (
    $result === FALSE) { return FALSE; };
        
    $entries ldap_get_entries($ad$result);
        if (
    $entries['count'] <= 0) { return FALSE; };
        if (empty(
    $entries[0]['memberof'])) { return FALSE; } else {
            for (
    $i 0$i $entries[0]['memberof']['count']; $i++) {
                if (
    $entries[0]['memberof'][$i] == $groupdn) { return TRUE; }
                elseif (
    checkGroupEx($ad$entries[0]['memberof'][$i], $groupdn)) { return TRUE; };
            };
        };
        return 
    FALSE;
    }

    ?>

  14. Thanks to glennda from:

    FN-GM (31st January 2012)

  15. #12

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    Thanks guys will give it a shot.

    Thanks

  16. #13

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Not a problem - anything else post up and i'll try n help! got 3 hours to kill!

  17. #14

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,942
    Thank Post
    886
    Thanked 1,694 Times in 1,472 Posts
    Blog Entries
    12
    Rep Power
    447
    Quote Originally Posted by glennda View Post
    Not a problem - anything else post up and i'll try n help! got 3 hours to kill!
    What you doing in KUL?

    Quote Originally Posted by Arthur View Post
    PowerShell?

    Code:
    if(!(Get-PSSnapin | Where {$_.name -eq "Quest.ActiveRoles.ADManagement"})) { 
        Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction 0 | Out-Null
    }
    
    @(Get-QADGroupMember "Example Group" -Enabled).count
    
    
    # or
    
    
    Get-QADGroup "Example Group" -SizeLimit 0 | Select-Object Name,@{n='MemberCount';e={ (Get-QADGroupMember $_ | Measure-Object).Count}}
    Just to push it a little - Do you know how to make it so an input box appears asking for the group name rather than having to edit the script every time i would like to use it?

    Thanks

  18. #15


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,878
    Thank Post
    226
    Thanked 2,669 Times in 1,968 Posts
    Rep Power
    786
    Quote Originally Posted by FN-GM View Post
    Do you know how to make it so an input box appears asking for the group name rather than having to edit the script every time
    Here's one way of doing it...

    Code:
    Get-QADGroup (Read-Host "Enter your group name") -SizeLimit 0 | Select-Object Name,@{n='MemberCount';e={ (Get-QADGroupMember $_ | Measure-Object).Count}}
    Edit. Also worth mentioning is that if you have lots of groups with a similar names e.g. group1, group2, etc. You can simply enter group* when prompted.
    Last edited by Arthur; 31st January 2012 at 04:58 AM.

  19. Thanks to Arthur from:

    FN-GM (31st January 2012)

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Making better use of space in an ICT Suite
    By Little-Miss in forum How do you do....it?
    Replies: 15
    Last Post: 21st January 2014, 09:31 AM
  2. Multipoint Server in an AD environment
    By craigw in forum Thin Client and Virtual Machines
    Replies: 2
    Last Post: 15th February 2011, 08:14 AM
  3. [Fog] Fog Documentation: How to delete a group of computers in FOG
    By ssx4life in forum O/S Deployment
    Replies: 1
    Last Post: 9th November 2009, 01:59 PM
  4. how can i bulk add users to a an AD group
    By goodhead in forum Windows
    Replies: 5
    Last Post: 4th December 2008, 06:32 PM
  5. Replies: 5
    Last Post: 15th August 2008, 10:19 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •