add TPM Version and set date and time
This commit is contained in:
@@ -20,11 +20,27 @@ param(
|
||||
# This will fetch the script and execute it under pwsh so instruction-set detection works.
|
||||
|
||||
function Get-TPMStatus {
|
||||
# Try CIM first (Windows 10/11)
|
||||
# Prefer the Get-Tpm cmdlet when available (gives clear SpecVersion/ManufacturerVersion)
|
||||
try {
|
||||
if (Get-Command -Name Get-Tpm -ErrorAction SilentlyContinue) {
|
||||
$g = Get-Tpm -ErrorAction Stop
|
||||
$spec = $null
|
||||
if ($g.SpecVersion) { $spec = ($g.SpecVersion -join ', ') } elseif ($g.SpecVersion -ne $null) { $spec = [string]$g.SpecVersion }
|
||||
$manVer = $null
|
||||
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 }
|
||||
}
|
||||
} catch { }
|
||||
|
||||
# Try CIM (Win32_Tpm) as a fallback
|
||||
try {
|
||||
$tpm = Get-CimInstance -Namespace "root\cimv2\security\microsofttpm" -ClassName Win32_Tpm -ErrorAction Stop
|
||||
if ($tpm -and $tpm.IsEnabled_InitialValue -ne $null) {
|
||||
return @{ Installed = $true; IsEnabled = ($tpm.IsActivated_InitialValue -eq $true) -or ($tpm.IsEnabled_InitialValue -eq $true); ManufacturerId = $tpm.ManufacturerID; SpecVersion = $tpm.SpecVersion }
|
||||
$spec = $null
|
||||
try { if ($tpm.SpecVersion) { $spec = ($tpm.SpecVersion -join ', ') } } catch { $spec = $tpm.SpecVersion }
|
||||
$manVer = $null
|
||||
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 }
|
||||
}
|
||||
} catch {
|
||||
# fallback to registry check
|
||||
@@ -33,9 +49,9 @@ function Get-TPMStatus {
|
||||
# Registry fallback (may require elevated privileges)
|
||||
try {
|
||||
$reg = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\TPM' -ErrorAction Stop
|
||||
return @{ Installed = $true; IsEnabled = $true; ManufacturerId = $null; SpecVersion = $null }
|
||||
return @{ Installed = $true; IsEnabled = $true; ManufacturerId = $null; SpecVersion = $null; ManufacturerVersion = $null }
|
||||
} catch {
|
||||
return @{ Installed = $false; IsEnabled = $false; ManufacturerId = $null; SpecVersion = $null }
|
||||
return @{ Installed = $false; IsEnabled = $false; ManufacturerId = $null; SpecVersion = $null; ManufacturerVersion = $null }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,12 +206,17 @@ $result.MainDrive = Get-MainDriveInfo
|
||||
|
||||
function Format-ResultText($res) {
|
||||
$lines = @()
|
||||
$lines += "System Hardware & Security Report - $(Get-Date -Format 'u')"
|
||||
# Format date as MM-DD-YYYY and time as 12-hour with AM/PM
|
||||
$dt = Get-Date
|
||||
$lines += "System Hardware & Security Report - $($dt.ToString('MM-dd-yyyy hh:mm tt'))"
|
||||
$lines += ""
|
||||
$lines += "TPM Installed: $($res.TPM.Installed)"
|
||||
$lines += "TPM Enabled/Activated: $($res.TPM.IsEnabled)"
|
||||
if ($res.TPM.ManufacturerId) { $lines += "TPM ManufacturerId: $($res.TPM.ManufacturerId)" }
|
||||
if ($res.TPM.SpecVersion) { $lines += "TPM SpecVersion: $($res.TPM.SpecVersion)" }
|
||||
$manVer = if ($res.TPM.ManufacturerVersion) { $res.TPM.ManufacturerVersion } else { 'Not detected' }
|
||||
$specVer = if ($res.TPM.SpecVersion) { $res.TPM.SpecVersion } else { 'Not detected' }
|
||||
$lines += "TPM ManufacturerVersion: $manVer"
|
||||
$lines += "TPM SpecVersion: $specVer"
|
||||
$lines += ""
|
||||
$sb = $res.SecureBoot
|
||||
if ($sb -eq $null) { $lines += "Secure Boot: Unknown (insufficient privileges or unsupported)" } else { $lines += "Secure Boot Enabled: $sb" }
|
||||
|
||||
@@ -62,13 +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):
|
||||
- Execute directly (preferred when you trust the source):
|
||||
|
||||
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 -
|
||||
```
|
||||
|
||||
# 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 -
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user