Skip to content

Instantly share code, notes, and snippets.

@asheroto
Last active September 6, 2023 17:21
Show Gist options
  • Save asheroto/10d69b6bcb93296c5684a5ca750927aa to your computer and use it in GitHub Desktop.
Save asheroto/10d69b6bcb93296c5684a5ca750927aa to your computer and use it in GitHub Desktop.
Retrieves the Intel process generation. CPU generation as described here: https://www.intel.com/content/www/us/en/support/articles/000032203/processors/intel-core-processors.html

Get-IntelProcessorGeneration

Retrieves the Intel process generation. CPU generation as described here.

image

function Get-IntelProcessorGeneration {
<#
.SYNOPSIS
Returns the generation number of the Intel processor.
.DESCRIPTION
Returns the generation number of the Intel processor by parsing the processor name.
More information: https://www.intel.com/content/www/us/en/support/articles/000032203/processors/intel-core-processors.html
.EXAMPLE
PS C:\> Get-IntelProcessorGeneration
#>
$ProcessorInfo = (Get-CimInstance -ClassName Win32_Processor).Name
if ($ProcessorInfo -match 'i\d+-\d+') {
$procMatch = $matches[0]
$genString = $procMatch.Split('-')[1]
if ($genString.Length -eq 4) {
# If it's a 4 digit number after the dash, get the first number
$generationNumber = [int]($genString.Substring(0, 1))
} elseif ($genString.Length -eq 5) {
# If it's a 5 digit number after the dash, get the first two numbers
$generationNumber = [int]($genString.Substring(0, 2))
} else {
return -1
}
return $generationNumber
} else {
return -1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment