Ever wondered how old your Windows installation is? A one-liner can tell:
PS> (Get-CimInstance -Class Win32_OperatingSystem).InstallDate Freitag, 8. Juni 2018 18:24:46
Two things are noteworthy: first, we are apparently using a German system. Second, the install date may be much more recent than you think: every new major Windows 10 update actually performs a full reinstall.
If you’d like to change the culture for a DateTime output, simply use ToString() and a CultureInfo object:
PS> (Get-CimInstance -Class Win32_OperatingSystem).InstallDate.ToString([System.Globalization.CultureInfo]'en-us') 6/8/2018 6:24:46 PM PS>
And if you’d like to know just how old your Windows installation is in days, use New-TimeSpan:
PS> New-TimeSpan -Start (Get-CimInstance -Class Win32_OperatingSystem).InstallDate Days : 204 Hours : 18 Minutes : 53 Seconds : 52 Milliseconds : 313 Ticks : 176936323133869 TotalDays : 204,787411034571 TotalHours : 4914,89786482969 TotalMinutes : 294893,871889782 TotalSeconds : 17693632,3133869 TotalMilliseconds : 17693632313,3869 PS> (New-TimeSpan -Start (Get-CimInstance -Class Win32_OperatingSystem).InstallDate).TotalDays 204,78764150864 PS> (New-TimeSpan -Start (Get-CimInstance -Class Win32_OperatingSystem).InstallDate).Days 204
psconf.eu – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit www.psconf.eu There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at www.psconf.eu, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!