---
updatedAt: 2025-08-14T13:35:45.000Z
agentTools:
  siteIndex: https://developer.n-able.com/llms.txt
  projectIndex: https://developer.n-able.com/n-central/llms.txt
---

# Get Device Age

```powershell PowerShell
$ErrorActionPreference = "Stop"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
IF($objDomain.exist)
{$strCategory = "computer"
 
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"
$netlist = "." + " "   #local computer
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
	{$netlist +=$objResult.Properties.name[0] + " " } }
else {
Get-WmiObject Win32_ComputerSystem | Foreach-Object {$compname =$_.Name}
Write-Host $compname }
$machs = $netlist.split(" ")
Foreach($mach in $machs)
{Get-WmiObject Win32_Bios -ComputerName $mach | Foreach-Object {$BDYear = $_.ReleaseDate.Substring(0,4) ; $BDMonth = $_.ReleaseDate.Substring(5,1)}} # Write-Host $mach  "is"  $_.ReleaseDate.Substring(0,4)  "years old"}}
$DateNow = Get-Date
$NDYaer = $DateNow.Year 
$NDMonth = $DateNow.Month
$AgeYears = $NDYaer - $BDYear
If ($NDMonth -gt $BDMonth)
{$AgeMonth =$NDMonth-$BDMonth ;
$Age = $AgeYears.ToString() + " Years" + $AgeMonth.ToString() +  " Months"}
else
{$Age = $AgeYears.ToString() + " Years "}
Write-Host "This computer is " $Age  " old"
```

```json Response Example
{"success":true}
```

# SCRIPT