/build/static/layout/Breadcrumb_cap_w.png

Getting an accurate count of computers in your domain. (Using the K1000)

If you ever need to know the number of computers in your domain there is an easy way to perform the search utilizing the K1000 Appliance and a command run on your Domain Controller.  

 

An LDAP query will show you the number of existing computer accounts but it cannot distinguish which accounts have not been used for a give period of time (Since you last retired computers)  If you are not unjoining your computers from the domain before you retire them, then you will likely have stale records in AD.  This can be a problem if you are trying to get a count of computers to purchase a computer based software license (such as a new K1000 or are adding nodes to a K1000)

 

In the K1000 Appliance, go to Home > Labels > LDAP Labels.

Create a new LDAP Label and enter the servername or IP, and the port 389 (636 if you use LDAPS)

Also enter an administrative LDAP login (in the format of domain\username) and LDAP Password.

Click LDAP Browser, then click Test.

If the connection is successful then click next.

The Search Base DN should already be at the root of your Domain.

In the Search Filter box enter: (objectcategory=computer)

Make a note of the Search Count in the right hand pane.

 

Now log into your Domain Controller and open a command prompt.

Run the command: "dsquery computer -inactive X"  Where X is the number of weeks since you last retired a system. (If it has been 2.5 weeks then enter 2) Make note of the number of results.

Next, Run the command "dsquery computer -disabled"  Make note of the number of results.

If you have a large number of results you can have the command output to a text file by adding  "> c:\inactive.txt" or "> c:\disabled.txt" to the end of your commands.  Open the file in notepad (make sure Word Wrap is off and Status Bar is on) Go to the last line of the document and your count will be shown in the bottom right corner as "Ln X" The X is your count.

 

Now for some basic arithmetic.

For a count of all active systems use the following formula

(K1000 Count) - (# inactive) - (#disabled) = Total Active

If you are adding nodes to your K1000 use the following formula

(K1000 Count) - (# inactive) - (#disabled) - (Current # in K1000 Inventory) = Total Nodes to purchase.

 

I hope this has been helpful.

 

 

 


Comments

  • Great article!
    I took that and ran with it to help do a count all within AD.

    dsquery computer DC=goose-nest,DC=org

    That counts all computers and servers in my AD

    Then, I counted those:
    dsquery computer DC=goose-nest,DC=org | find /c "CN"

    that gave me 25

    Then, i wanted to omit any machines that are inactive using the above:

    dsquery computer -inactive 2 | find /c “CN
    That gave me 5 computers.

    25-5 = 20 active computers - brucegoose03 7 years ago
  • dsquery user DC=goose-nest,DC=org | find /c "CN"
    52

    used that for users - brucegoose03 7 years ago
  • If it would help anyone, here's a PowerShell script I created from WhitzEnd's great article:

    $allObjects = dsquery computer -limit 0 "dc=domain,dc=tld" # Change to your domain DN
    $inactiveObjects = dsquery computer -inactive 2 -limit 0 # Set 2 weeks of inactivity
    $disabledObjects = dsquery computer -disabled
    $totalObjects = $allObjects.count - $inactiveObjects.count - $disabledObjects.count

    Write-Host "Total Computer Count: " $totalObjects - NerdZone 6 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ