I'm getting information on monitors from WMI. There are properties called "WeekOfManufacture" and "YearOfManufacture". In this case it's:
Week : 24 Year : 2009
I'm trying to get the approximate date corresponding to that.
I'm doing this to get a really rough estimate:
(Get-Date -Date $YearOfManufacture/01/01).AddDays(7*$WeekOfManufacture)
But obviously the "week" doesn't necessarily always have 7 days.
What is the best approach?
The complete code I'm using right now is:
$Monitors = Get-WmiObject WmiMonitorID -Namespace root\wmi
foreach ($Monitor in $Monitors) {
$Manufacturer = ($Monitor.ManufacturerName -notmatch 0 | ForEach{[char]$_}) -join ""
$Code = ($Monitor.ProductCodeID -notmatch 0 | ForEach{[char]$_}) -join ""
$Name = ($Monitor.UserFriendlyName -notmatch 0 | ForEach{[char]$_}) -join ""
$Serial = ($Monitor.SerialNumberID -notmatch 0 | ForEach{[char]$_}) -join ""
$WeekOfManufacture = $Monitor.WeekOfManufacture
$YearOfManufacture = $Monitor.YearOfManufacture
$DateManufacture = (get-date -Date $YearOfManufacture/01/01).AddDays(7*$WeekOfManufacture)
"$Manufacturer - $Code - $Name - $Serial - $DateManufacture"
}
which returns something like (info obfuscated):
SAM - 1234 - SycMastr - XXXX - 06/18/2009 00:00:00 SAM - 1234 - SycMastr - XXXX - 09/10/2009 00:00:00