From eb924f7cdf0dc93c0e96813d06fa0e2433418845 Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Thu, 3 Jul 2025 13:45:43 -0400 Subject: [PATCH] Update Ensure-RealBitLockerKey.ps1 --- Ensure-RealBitLockerKey.ps1 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Ensure-RealBitLockerKey.ps1 b/Ensure-RealBitLockerKey.ps1 index e2625d3..82c2cc2 100644 --- a/Ensure-RealBitLockerKey.ps1 +++ b/Ensure-RealBitLockerKey.ps1 @@ -95,8 +95,19 @@ function Ensure-RealBitLockerKey { $auditString = $null if ($PersistToRegistry) { # Build audit - $alert = $env:usrAlert -match 'true' ? 'Notice' : 'Status' - $t = Get-Tpm; $mask = ($t.TpmPresent?1:0) + ($t.TpmReady?6:0) + # Powershell 7 + #$alert = $env:usrAlert -match 'true' ? 'Notice' : 'Status' + + # powershell 5 + if ($env:usrAlert -match 'true') { + $alert = 'Notice' + } else { + $alert = 'Status ...' + } + + $t = Get-Tpm; $mask = (if ($t.TpmPresent) { 1 } else { 0 }) + (if ($t.TpmReady) { 6 } else { 0 })# PoSH 7 $mask = ($t.TpmPresent?1:0) + ($t.TpmReady?6:0) + + switch ($mask) {0{'Absent'};1{'Disabled'};3{'Deactivated'};7{'Active'};default{'Error'}} | Out-Null $drives=$AllDisks?($targets):(,$d) $diskStatus=''