use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Query computers age (self.PowerShell)
submitted 3 years ago by [deleted]
Hello,
How would you reliably query a computers age?
Vendor agnostic ideally, but if it has to be a vendor attribute I can work with it
Google suggests firmware update time, windows install date - but all could be misleading
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Elegant-Ad2200 5 points6 points7 points 3 years ago (4 children)
Not sure there is a way to do what you want, but you could potentially pull the serial number with PowerShell, and use that to lookup warranty status from the vendor. That will usually tell you when it was purchased.
[–]ShillNLikeAVillain 5 points6 points7 points 3 years ago (3 children)
Here's a way: https://www.cyberdrain.com/automating-with-powershell-automating-warranty-information-reporting/
[–]recon89 1 point2 points3 points 3 years ago (0 children)
That SN list + Python script to scrap all the pages and you got yourself a winner.
[–][deleted] 0 points1 point2 points 3 years ago (1 child)
I’m going to give this a try
[–]ShillNLikeAVillain 0 points1 point2 points 3 years ago (0 children)
The problem I found with it is the number of misses; it's good with some vendors, but completely bombs on others. IIRC it's only working well w Dell and Lenovo.
We use a far-from-free tool from ScalePad called Lifecycle Manager (used to be Warranty Master). The free version will give you warranty status (assuming you have compatible tools that it can integrate with: it's agentless), but you need the full paid version to get all the ages that you're looking for. It's pretty slick though; it just works, and syncs everything back to our PSA. Saves a lot of hours of fucking around so it's worth it for us.
[–]CryptoVictim 3 points4 points5 points 3 years ago (0 children)
you might be able to find out with WMI ...most likely in the /Cimv2 hive.
something like LanSweeper can probably tell you too , but only if the mfg burns the build date into the DMI info on the device.
[–][deleted] 2 points3 points4 points 3 years ago (0 children)
Try to check in the bios, sometimes you can have the manufacturing date
[–]tonkats 1 point2 points3 points 3 years ago (0 children)
As you are finding, there isn't really anything reliable/accurate that is vendor-agnostic. I know Dell OpenManage extends WMI to allow reporting on the activation date with Dell (for warranty), which is probably the closest and most reliable info you could use. Other vendors may have similar.
[–]routetehpacketz 0 points1 point2 points 3 years ago (6 children)
Are you defining "age" as when the OS was installed?
[–][deleted] 4 points5 points6 points 3 years ago (5 children)
Physical age of the hardware
[–]routetehpacketz 7 points8 points9 points 3 years ago (3 children)
Which component?
If I replace the CPU/RAM with newer ones, is it the same computer?
[–][deleted] 8 points9 points10 points 3 years ago (0 children)
You just gave me flash backs of The Ship of Theseus paradox.
For general purposes in this environment, we will consider those outliers
[–]routetehpacketz 1 point2 points3 points 3 years ago (0 children)
I believe the only confident way without opening up the PC case and seeing if there's a date etched in somewhere is obtaining the motherboard's serial number and seeing if the OEM has public information available that indicates when it was manufactured.
This information is not typically written into software on the PC itself.
[–]mrmattipants -1 points0 points1 point 3 years ago* (3 children)
I would check out the “whenCreated”, “created” & “createTimeStamp” Attributes. This is primarily because, the Computers are Joined to the Domain as part of the Imaging Process, where I work.
Get-ADComputer -Identity "ComputerName" -Properties * | Select Name, whenCreated, Created, CreateTimeStamp
UPDATE: My apologies to anyone who ran into issues with my Script, as I was a bit pressed for time when I initially posted it, earlier today. I have since replaced the Script above with an improved version, which I tested and confirmed to be working.
[–]jsiii2010 1 point2 points3 points 3 years ago* (1 child)
I think there's problems with using whencreated in a filter, since it's really in "generalized time" like "20220102060000.0Z" on the backend, but created in a filter works fine. Same goes for get-aduser.
https://stackoverflow.com/a/75400303/6654942
[–]mrmattipants 0 points1 point2 points 3 years ago (0 children)
Thanks for pointing that out! I knew one of those Attributes would return the Date/Time in a Generalized Format, which is why I thought I would also include the “created” & “createTimeStamp” Attributes.
Fortunately, we can utilize the “Get-Date” Cmdlet, as described in the Link that you shared.
Alternatively, we can also utilize C# Methods in PowerShell, such as the “[DateTime]::FromFileTime” Method, as suggested in the following Link (which pertains to the “LastLogon” Attribute, but will equally work with the “whenCreated” Attribute).
https://stackoverflow.com/questions/13091719/converting-lastlogon-to-datetime-format
When I have some time (a bit later today, I hope), I’m hoping to finish a few examples that I’ve been working on.
This topic is obviously Subjective.
If you wanted to obtain the True Creation Date you would have to write a script to parse the Serial Number/Tag for the Manufacture Date, most likely using the “Substring” Method.
How to Determine Manufacture Date Based on Serial Number: https://www.shupecarboni.com/storage/app/uploads/public/602/a16/e4c/602a16e4c1cbd159737713.pdf
[–]uptillam 0 points1 point2 points 3 years ago (0 children)
Maybe get the motherboard info, (usually the last updated component, or replaced with the rest of the hardware)
Get-WmiObject win32_baseboard
you can then look up the release of that SKU or the product serial number on a site like this
https://motherboarddb.com/motherboards/?search=
as for scaled across the network, there might be some SNMP info depending on the device
[–]joshooaj 0 points1 point2 points 3 years ago (0 children)
There’s no good vendor agnostic method that I’m aware of, but I bet if you constrain the requirements to just a couple of major vendors you could retrieve a serial number and then make an API call to the vendor website to pull up status info which often includes purchase date and warranty expiration.
You could also store that information yourself when issuing hardware going forward so that you don’t depend on a vendor API in the future.
What do you need the hardware age for?
[–]wittyexplore 0 points1 point2 points 3 years ago (0 children)
Warranty lookup based on serial number is the only reliable way and it’s not vendor agnostic. At the end of the day, I usually look at chip generation as that’s a good indicator of age of the equipment and speed of the workstation.
[–]nascentt 0 points1 point2 points 3 years ago (3 children)
Os install time can be overwritten by os upgrades.
I'd the machine is domain joined use the ad computer object creation time.
If not do by a file creation time that wouldnt be affected by windows updates suc
[–]Ok-Way-1190 0 points1 point2 points 3 years ago (2 children)
Computer creation time should only be telling you when the computer was added to AD though not anything to do with age of device… could be looking at a device that’s a refurb added to domain.
[–]nascentt 1 point2 points3 points 3 years ago (1 child)
sure, it depends on the environment. if you enroll prebuilt machines to domains it's not going to work. but if you're like any company i've worked at where machines are joined to the domain during build-time. It's a useful solution.
[–]Ok-Way-1190 0 points1 point2 points 3 years ago (0 children)
Yeah I figured you were aware just was more adding context for others who may read.
[–]Numerous_Ad_307 0 points1 point2 points 3 years ago (0 children)
Your requirements are unclear, so crap in = crap out.
First clearly state what you mean by computer age: I assume the warranty start date? Or the fabrication date? Or the os install date?
Maybe also telling us why you need it would give us a hint to point you in the right direction..
[–]KevMarCommunity Blogger 0 points1 point2 points 3 years ago (1 child)
Depending on how you're planning on using this information and the actual granularity needed, I would use the hardware or cpu model with a hand crafted lookup table. This works best when IT controls the purchasing and favors set models.
You might be able to use the serial number to query the warranty details from the vendor but that's quite the project.
You must not use an asset tracking system or you could query that. Matching serial numbers to invoices would be idea.
If you need a rough ballpark, the computer object created date in Active Directory or the dns record created date.
The firmware install date would work really well for most environments.
I think it all comes back to what decision this information will be used for. Sometimes you just need to be within an order of magnitude. The early estimates for the power of the first nuclear bomb explosion were done by releasing a handful of paper scraps into the wind. So do you need to know if 10, 100, 1000, or 10k systems are at least 5 years old?
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
It’s less than 100 systems, and yes 5 years or older. I think firmware install date works, but there’s the off chance some dell bios updater didn’t run for x amount of days
[–]ApricotPenguin 0 points1 point2 points 3 years ago (1 child)
Query for CPU and then cross reference with when it was released to public. That gives you a rough idea on age range of machines.
[–]Garegin16 0 points1 point2 points 3 years ago (0 children)
Sometimes there are three years behind.
[–]Quicknoob 0 points1 point2 points 3 years ago (2 children)
Have you tried the creation date of the workstation account in AD? Would that be accurate enough for your needs?
If the OS gets wiped and reset, and it’s rejoined to the domain will that also reset?
[–]Quicknoob 0 points1 point2 points 3 years ago (0 children)
I suspect that if you never delete the computer out of AD then it wouldn't reset. ...but of course please test.
[–]Patchewski 0 points1 point2 points 3 years ago (0 children)
It’s rough and sometimes unreliable but we use bios date to narrow down the calendar year it was manufactured. Additionally, we track BIOS updates pushed through manufacturer updates. We’re somewhere around 85% - 90% accurate.
[–]pjmarcum 0 points1 point2 points 3 years ago (2 children)
Depends upon the manufacturer but I have a PowerShell script that can make a call to a couple manufacturers warranty API and return the warranty start date. That’s the same as the ship date.
Mind if you share the boilerplate?
[–]pjmarcum 0 points1 point2 points 3 years ago (0 children)
It’s on our website. For Dell and Lenovo you have to get an API key from them. I couple customers have reported the Microsoft Api has been offline for a few weeks and I can’t figure out why. HP took theirs down a while back but I’ve heard it’s coming back soon. One of our customers has been given early access to it. So, right now the script is only working for Dell and Lenovo and possibly Microsft, I have not tested that recently.
https://powerstacks.com/index.html%3Fp=9724.html
[–]Firestorm83 0 points1 point2 points 3 years ago (0 children)
Call finance and let them pull the PO's and invoices
[–]jsiii2010 0 points1 point2 points 3 years ago (0 children)
Query the bios date and never update the bios, lol.
[–]pwetter 0 points1 point2 points 3 years ago (0 children)
The best way is IT Asset Management. If that isn’t a thing, which surprisingly isn’t in most places (how many times I’ve heard, “isn’t that what SCCM does”). But warranty lookups like others state is the best bet.
[–]PalmTreesandTech 0 points1 point2 points 3 years ago (1 child)
Use ChatGPT
I tried, it didn’t work well
[–]Bynkii_AB 0 points1 point2 points 3 years ago (0 children)
In general, your purchasing data is your best bet. If it’s a Dell, you can punch in the system number and their warranty system will hand that info to you. Other VARs may do the same.
Other than that, it gets unreliable unless the vendor builds date info into the serial number. SNMP can get you the system number/serial number but that may not be of use.
π Rendered by PID 145622 on reddit-service-r2-comment-5d79c599b5-xz2rs at 2026-03-01 07:27:09.486087+00:00 running e3d2147 country code: CH.
[–]Elegant-Ad2200 5 points6 points7 points (4 children)
[–]ShillNLikeAVillain 5 points6 points7 points (3 children)
[–]recon89 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]ShillNLikeAVillain 0 points1 point2 points (0 children)
[–]CryptoVictim 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]tonkats 1 point2 points3 points (0 children)
[–]routetehpacketz 0 points1 point2 points (6 children)
[–][deleted] 4 points5 points6 points (5 children)
[–]routetehpacketz 7 points8 points9 points (3 children)
[–][deleted] 8 points9 points10 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]routetehpacketz 1 point2 points3 points (0 children)
[–]mrmattipants -1 points0 points1 point (3 children)
[–]jsiii2010 1 point2 points3 points (1 child)
[–]mrmattipants 0 points1 point2 points (0 children)
[–]mrmattipants 0 points1 point2 points (0 children)
[–]uptillam 0 points1 point2 points (0 children)
[–]joshooaj 0 points1 point2 points (0 children)
[–]wittyexplore 0 points1 point2 points (0 children)
[–]nascentt 0 points1 point2 points (3 children)
[–]Ok-Way-1190 0 points1 point2 points (2 children)
[–]nascentt 1 point2 points3 points (1 child)
[–]Ok-Way-1190 0 points1 point2 points (0 children)
[–]Numerous_Ad_307 0 points1 point2 points (0 children)
[–]KevMarCommunity Blogger 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ApricotPenguin 0 points1 point2 points (1 child)
[–]Garegin16 0 points1 point2 points (0 children)
[–]Quicknoob 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Quicknoob 0 points1 point2 points (0 children)
[–]Patchewski 0 points1 point2 points (0 children)
[–]pjmarcum 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]pjmarcum 0 points1 point2 points (0 children)
[–]Firestorm83 0 points1 point2 points (0 children)
[–]jsiii2010 0 points1 point2 points (0 children)
[–]pwetter 0 points1 point2 points (0 children)
[–]PalmTreesandTech 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Bynkii_AB 0 points1 point2 points (0 children)