active devices and OS

Is there an easy way, perhaps via one of the ad cmdlets, to get a CSV report of all computers in the domain, that have been "in use" in the past 14 days, to include their computer name, and most importantly their operating system. We are trying to determine, how many, or if any, XP devices are still in use within our primary domain.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
You can use the script below.

import-module activedirectory
$Date = Get-Date
Get-ADComputer -Filter * -Properties Name, OperatingSystem, LastLogonDate | ? { $_.LastLogonDate -lt $Date.AddDays(-14) } | 
Select Name, OperatingSystem, LastLogonDate |
Export-csv "c:\computers.csv" -nti

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pma111Author Commented:
Hi will for commands where there is a few lines, do you have to put these in a text document and save as a ps script, or can you just copy / paste the text into the console and execute (currently dont have access to a domain to test).
Will SzymkowskiSenior Solution ArchitectCommented:
You can do one of two things...
- copy the script
- paste it into Notepad
- save the file as a .PS1 file extension
- open a powershell session
- navigate to where you saved the script
- type .\scriptname.ps1

This will run the script for you.

- copy the script and paste it into the Powershell ISE
- Run the script from the ISE

Thats it.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.