List all workstations in the domain

Here’s another quick oneliner I had to create for someone today and wanted to share with you:

Get-QADComputer -ComputerRole member -SizeLimit 0 -OSName 'Windows XP*', 'Windows 2000 Professional', 'Windows 7*', 'Windows Vista*'

The initial one-liner the customer was using was retrieving all Member computers but then using Where to filter by $_.operatingsystem whatever did not have Server in the name. This took longer (because Where is filtering on the client side after all objects are already retrieved) and resulted in extra computers being reported such as non-Windows storage systems.

Using cmdlet parameters makes sure that filtering is done during the object retrieval which is more efficient. And, as you can see, OSName parameter – as most parameters in QAD cmdlets – supports multiple values.

Depending on your environment you might want to modify the OS list to include Windows 8 or Mac OS😉

If you want to get full list of operating systems in use in your company you would probably execute something like:

Get-QADComputer -SizeLimit 0 | group operatingsystem | sort Count -Descending

Hope this helps!

7 Responses to “List all workstations in the domain”


  1. 1 dboftlp May 5, 2010 at 8:20 pm

    in the -OSName filter, couldn’t you just have used “Windows*”?
    I used something similar but in an -LdapFilter so I could get just Windows systems and also filter by lastlogintimestamp or pwdLastSet in the LdapFilter

    • 2 Dmitry Sotnikov May 5, 2010 at 8:37 pm

      This particular customer did not want their servers listed – so I specifically used Windows client OS names.

      Yes, adding lastlogintimestamp or pwdLastSet can further filter out old accounts. Good point.

  2. 3 scs68 May 6, 2010 at 5:50 pm

    I get this error when trying to run the script:

    Cannot convert ‘System.Object[]’ to the type ‘System.String’ required by parameter ‘OSName’. Specified method is not supported.
    At :line:1 char:57
    + Get-QADComputer -ComputerRole Member -SizeLimit 0 -OSname <<<< 'Windows XP*', 'Windows 2000 Professional', 'Windows 7*', 'Windows Vista*'

    Thoughts?

  3. 5 Michelle Smith May 1, 2013 at 3:37 pm

    how can you query for a negative for example get-qadcomputer -name -notlike cl*

  4. 6 Brian December 6, 2013 at 8:39 pm

    Michelle – I think you might be able to do it like this:

    Get-QADComputer -ComputerRole member -SizeLimit 0 | where {!($_.name -match “^[cl]”)}

    Good luck,
    Brian


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




My Recent Tweets

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

May 2010
M T W T F S S
« Apr   Jun »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

%d bloggers like this: