By using Active Directory or PowerShell, you can count the number of remaining Windows XP computers in your organization.

How many XP machines do you have? What other operating systems do you support? Though these questions sound easy, getting correct counts can be surprisingly difficult. By using Active Directory and PowerShell, you can quickly generate accurate reports that breakdown your OS count. With Windows XP’s end of life coming quickly, this report can help you migrate more machines, faster!

Count with Active Directory

Each active computer object in Active Directory will populate three operating system attributes. The operatingSystem attribute stores the current OS name, operatingSystemServicePack records the service pack level, and OperatingSystemVersion lists the OS version value. In Active Directory Users and Computers (ADUC), view the properties of a computer account and select the Operating System tab to view this information.

Viewing the AD OS details for a Windows XP SP3 computer object

Viewing the AD OS details for a Windows XP SP3 computer object

Because our reports will rely on correct and active computer accounts, it is important that stale computer accounts be regularly pruned from Active Directory. PowerShell makes computer account maintenance easy. If you aren’t regularly cleaning out AD, take a look at this guide now. Now that you are confident that Active Directory is accurate, it is time to make our first report with ADUC.

At the top of the ADUC MMC, right click on Saved Queries and New – Query. Name your query Windows XP Computers and type a brief description. Select Define Query. Under the Find menu, change your search to Computers and then choose the Advanced Tab. Select Field – Operating System and type Windows XP as the value.

Creating a custom ADUC query for our Windows XP machines

Creating a custom ADUC query for our Windows XP machines.

If you keep stale computer accounts in a specific OU, be sure that your query root does not include those objects. Though I find querying by name easier, you can also query by the OS version number. Just be sure that your search scope does not include any OUs with server operating systems or your client counts will be inflated. Here are the common version numbers:

  • XP: 5.1
  • XP 64-bit: 5.2
  • Vista: 6.0
  • Windows 7: 6.1
  • Windows 8: 6.2
  • Windows 8.1: 6.3

After you’ve created a custom query for each OS that you support, you can export the information to a CSV. Select the query, right click, and choose Export List to do so. Be sure that the query is highlighted or the Export List option will be unavailable.

Our completed ADUC OS queries for each OS that we support

Our completed ADUC OS queries for each OS that we support.

Count with PowerShell

Active Directory has already stored all of the data that we need. Querying it with PowerShell is simple. Where PowerShell stands out is in its manipulation of data and ability to create basic reports. Launch PowerShell ISE and import the Active Directory module (import-module ActiveDirectory). If you prefer or have to use the Quest AD cmdlets, see this guide for details.

To query for a specific OS, we can filter by the operating system name. For example, to list Windows XP machines:

Get-ADComputer –filter ‘OperatingSystem –eq “Windows XP”’

If you wanted to get a larger view with PowerShell, you could expand your filter and then sort by the operating system. For example:

Get-ADComputer –filter * -Properties * | Format-Table Name,OperatingSystem –AutoSize | Sort-object OperatingSystem

Listing and Sorting Operating Systems with PowerShell

Listing and Sorting operating systems with PowerShell

To make the list a little friendlier, we can modify the above commands and pipe our results to Out-GridView.

Get-ADComputer –filter * -Properties * | Select Name,OperatingSystem | Out-GridView

Out-GridView allows you to easily filter and sort custom data from PowerShell

Out-GridView allows you to easily filter and sort custom data from PowerShell

Finally, you can export any of this data to a CSV by removing the Out-GridView cmdlet and replacing with Export-CSV. From here, you can manipulate or share the data.

By using custom queries in ADUC or the Active Directory PowerShell cmdlets, you can generate accurate counts. You can finally know the computers you support and the operating systems running on them!

In the next part of our Windows XP end of life series you'learn how to deal with malware once Microsoft will end the support for this 14-years-old operating system.

0 Comments

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account