Retrieves the Intel process generation. CPU generation as described here.
Last active
September 6, 2023 17:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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