Reputation: 21
I need to find in my organization all the old machines like winxp or server 2003,win98 i ran this code but i dont get any error neither a result
get-adcomputer -filter * -properties name,operatingsystem | where-object {($_.operatingsystem -like "windows xp") -and ($_.operatingsystem -like "windows server 2003") -and ($_.operating system -like "windows 98")}
Upvotes: 0
Views: 123
Reputation: 839
First of all, as mentioned in the comments, you should use the logical operator OR. It is one or the other ... not all together.
Also, because using like, try to use a smaller keywords that would match like XP for Windows XP, 2003 for Windows Server 2003 and etc.
get-adcomputer -filter "operatingsystem -like '*xp*' -or operatingsystem -like '*2003*' -or operatingsystem -like '*98*'" -properties operatingsystem
What I would do personally is to export everything into CSV, put it into excel with table and filters and review in details. Sometimes the names look a bit strange (i.e. windows server 2008 has a strange symbol included like trademark, or something) and you will get more holistic view on the OS names
you may also do something like this to identify numbers:
get-adcomputer -filter * -properties operatingsystem | Group-Object -Property operatingsystem
Upvotes: 1