[CmdletBinding()] param( [switch]$AsJson ) $ErrorActionPreference = 'Stop' if (-not (Get-Command Get-BitLockerVolume -ErrorAction SilentlyContinue)) { Write-Error 'Командлет Get-BitLockerVolume недоступен. Нужны Windows Pro или Enterprise.' exit 2 } try { $volumes = @(Get-BitLockerVolume -ErrorAction Stop) } catch { Write-Error "Не удалось получить статус BitLocker: $($_.Exception.Message)" exit 2 } $result = @() foreach ($volume in $volumes) { $protectors = @($volume.KeyProtector | ForEach-Object { [string]$_.KeyProtectorType }) $result += [pscustomobject]@{ MountPoint = $volume.MountPoint VolumeStatus = [string]$volume.VolumeStatus ProtectionStatus = [string]$volume.ProtectionStatus EncryptionPercentage = $volume.EncryptionPercentage EncryptionMethod = [string]$volume.EncryptionMethod KeyProtectors = $protectors } } if ($AsJson) { $result | ConvertTo-Json -Depth 5 exit 0 } $result | Format-Table MountPoint, VolumeStatus, ProtectionStatus, EncryptionPercentage, EncryptionMethod -AutoSize $unprotected = @($result | Where-Object { $_.ProtectionStatus -ne 'On' }) if ($unprotected.Count -gt 0) { Write-Warning ("Без включённой защиты: " + (($unprotected | ForEach-Object { $_.MountPoint }) -join ', ')) exit 1 } Write-Host 'Все тома под защитой BitLocker.' exit 0