add TPM version

This commit is contained in:
minster586
2025-10-15 02:37:02 -04:00
parent 0e93b010a9
commit 5b2651d5a6
2 changed files with 20 additions and 9 deletions

View File

@@ -28,7 +28,14 @@ function Get-TPMStatus {
if ($g.SpecVersion) { $spec = ($g.SpecVersion -join ', ') } elseif ($g.SpecVersion -ne $null) { $spec = [string]$g.SpecVersion } if ($g.SpecVersion) { $spec = ($g.SpecVersion -join ', ') } elseif ($g.SpecVersion -ne $null) { $spec = [string]$g.SpecVersion }
$manVer = $null $manVer = $null
try { if ($g.ManufacturerVersion) { $manVer = $g.ManufacturerVersion } } catch { } try { if ($g.ManufacturerVersion) { $manVer = $g.ManufacturerVersion } } catch { }
return @{ Installed = ($g.TpmPresent -eq $true); IsEnabled = ($g.TpmReady -eq $true); ManufacturerId = $g.ManufacturerId; SpecVersion = $spec; ManufacturerVersion = $manVer } # Normalize spec version: make a raw string and extract primary (first) component
$specRaw = $null
$specPrimary = $null
if ($spec) {
if ($spec -is [System.Array]) { $specRaw = ($spec -join ', ') } else { $specRaw = [string]$spec }
$specPrimary = ($specRaw -split ',')[0].Trim()
}
return @{ Installed = ($g.TpmPresent -eq $true); IsEnabled = ($g.TpmReady -eq $true); ManufacturerId = $g.ManufacturerId; SpecVersionPrimary = $specPrimary; SpecVersionRaw = $specRaw; ManufacturerVersion = $manVer }
} }
} catch { } } catch { }
@@ -36,11 +43,14 @@ function Get-TPMStatus {
try { try {
$tpm = Get-CimInstance -Namespace "root\cimv2\security\microsofttpm" -ClassName Win32_Tpm -ErrorAction Stop $tpm = Get-CimInstance -Namespace "root\cimv2\security\microsofttpm" -ClassName Win32_Tpm -ErrorAction Stop
if ($tpm -and $tpm.IsEnabled_InitialValue -ne $null) { if ($tpm -and $tpm.IsEnabled_InitialValue -ne $null) {
$spec = $null $specRaw = $null
try { if ($tpm.SpecVersion) { $spec = ($tpm.SpecVersion -join ', ') } } catch { $spec = $tpm.SpecVersion } try {
if ($tpm.SpecVersion -is [System.Array]) { $specRaw = ($tpm.SpecVersion -join ', ') } else { $specRaw = [string]$tpm.SpecVersion }
} catch { $specRaw = [string]$tpm.SpecVersion }
$specPrimary = if ($specRaw) { ($specRaw -split ',')[0].Trim() } else { $null }
$manVer = $null $manVer = $null
try { if ($tpm.ManufacturerVersion) { $manVer = $tpm.ManufacturerVersion } } catch { } try { if ($tpm.ManufacturerVersion) { $manVer = $tpm.ManufacturerVersion } } catch { }
return @{ Installed = $true; IsEnabled = ($tpm.IsActivated_InitialValue -eq $true) -or ($tpm.IsEnabled_InitialValue -eq $true); ManufacturerId = $tpm.ManufacturerID; SpecVersion = $spec; ManufacturerVersion = $manVer } return @{ Installed = $true; IsEnabled = ($tpm.IsActivated_InitialValue -eq $true) -or ($tpm.IsEnabled_InitialValue -eq $true); ManufacturerId = $tpm.ManufacturerID; SpecVersionPrimary = $specPrimary; SpecVersionRaw = $specRaw; ManufacturerVersion = $manVer }
} }
} catch { } catch {
# fallback to registry check # fallback to registry check
@@ -214,9 +224,11 @@ function Format-ResultText($res) {
$lines += "TPM Enabled/Activated: $($res.TPM.IsEnabled)" $lines += "TPM Enabled/Activated: $($res.TPM.IsEnabled)"
if ($res.TPM.ManufacturerId) { $lines += "TPM ManufacturerId: $($res.TPM.ManufacturerId)" } if ($res.TPM.ManufacturerId) { $lines += "TPM ManufacturerId: $($res.TPM.ManufacturerId)" }
$manVer = if ($res.TPM.ManufacturerVersion) { $res.TPM.ManufacturerVersion } else { 'Not detected' } $manVer = if ($res.TPM.ManufacturerVersion) { $res.TPM.ManufacturerVersion } else { 'Not detected' }
$specVer = if ($res.TPM.SpecVersion) { $res.TPM.SpecVersion } else { 'Not detected' } $specPrimary = if ($res.TPM.SpecVersionPrimary) { $res.TPM.SpecVersionPrimary } else { 'Not detected' }
$specRaw = if ($res.TPM.SpecVersionRaw) { $res.TPM.SpecVersionRaw } else { 'Not detected' }
$lines += "TPM ManufacturerVersion: $manVer" $lines += "TPM ManufacturerVersion: $manVer"
$lines += "TPM SpecVersion: $specVer" $lines += "TPM SpecVersion (primary): $specPrimary"
$lines += "TPM SpecVersion (raw): $specRaw"
$lines += "" $lines += ""
$sb = $res.SecureBoot $sb = $res.SecureBoot
if ($sb -eq $null) { $lines += "Secure Boot: Unknown (insufficient privileges or unsupported)" } else { $lines += "Secure Boot Enabled: $sb" } if ($sb -eq $null) { $lines += "Secure Boot: Unknown (insufficient privileges or unsupported)" } else { $lines += "Secure Boot Enabled: $sb" }

View File

@@ -62,12 +62,11 @@ pwsh.exe -File .\Get-SystemSecurityAndHardwareInfo.ps1 -OutputFile report.txt
- Download and run directly from a raw GitHub URL (only if you trust the URL): - Download and run directly from a raw GitHub URL (only if you trust the URL):
- Execute directly (preferred when you trust the source): - Execute directly (preferred when you trust the source):
# Option A (safest single-line): fetch only the script text and pipe into pwsh for execution.
```powershell ```powershell
# Option A (safest single-line): fetch only the script text and pipe into pwsh for execution.
(iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1").Content | & pwsh -Command - (iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1").Content | & pwsh -Command -
```
# Option B (forces pwsh, similar to above but uses the response pipeline): # Option B (forces pwsh, similar to above but uses the response pipeline):
```
iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1" | & pwsh -Command - iwr -UseBasicParsing "https://git.smartcraft.me/Smartcraft-Media-Tech/System-Info/raw/branch/master/System%20Info%20%28ps1%29/Get-SystemSecurityAndHardwareInfo.ps1" | & pwsh -Command -
``` ```