none
Manage-BDE status formatting RRS feed

  • Question

  • Hello experts,

    I am trying to make a PS script that I can run against a text file full of computers in our organization to tell me whether the C volume is encrypted or not encrypted with bitlocker. 

    I have the following, but I can not get the format correct. I am trying to have the computername and conversion status show up in a table, so that I will have a list of all comptuers (there will be hundreds) and their conversion status. I can not figure out how to get conversion status to show it's value in the table.

    One step further, if I can get this working my next step was to somehow work this into the export-csv to make a spreadsheet of the data. 

    Thanks in advance!

    $computers = Get-Content C:\temp\computerlist.txt
    foreach ($computer in $computers) {Write-Host "Processing computer: $computer" -ForegroundColor green
    Try{
    Invoke-Command -AsJob -ComputerName $computer -ScriptBlock { 
    manage-bde -status | Select-String -Pattern "Conversion Status" | Select-Object "Conversion Status"
    }
    }
    Catch{Write-Host $_ -ForegroundColor red -BackgroundColor white}
    }
    Get-Job | Receive-Job -Keep | Format-Table PSComputerName, "Conversion Status" -AutoSize -Wrap

    Tuesday, December 1, 2015 6:12 PM

Answers

All replies

  • What about computers that have multiple volumes? If this is the case then your attempt will return multiple results.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 1, 2015 6:29 PM
    Moderator
  • Also, I would suggest perhaps the WMI Win32_EncryptableVolume class instead, if the PowerShell BitLocker cmdlets are not available to you.


    PS C:\> Get-WmiObject Win32_EncryptableVolume -Namespace root\CIMV2\Security\MicrosoftVolumeEncryption


    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 1, 2015 7:53 PM
    Moderator
  •  Function Get-BitlockerInfo()
         <#
        .SYNOPSIS
        Retrieves Bitlocker Encryption information.
        .DESCRIPTION
        Retrieves Bitlocker Encryption information from Multiple computers.
        .PARAMETER Machinelist
        File name and path of the file contains machine information.
        .B.N.E
        Bit-locker Not Enabled
        .EXAMPLE
        Get-BitlockerInfo -Machinelist C:\Users\jijo\Desktop\Check.txt -LogfileName C:\Users\jijo\Desktop\Bitlocker.csv
         
        #>
    {
        [CmdletBinding()]
        Param(
            [Parameter(Mandatory=$True)][string]$Machinelist,
            [Parameter(Mandatory=$True)] [String]$LogfileName
        )
        Clear-Host
        $machines=Get-Content -Path $Machinelist
        $Bitlockerforprint=@()
    Foreach($Computer  in $Machines)
        {
        $ping = Test-Connection  $Computer -Count 1 -ErrorAction SilentlyContinue
            if ($ping.statuscode -eq 0)
            {
                Try
                {
                $EncryptionStatus=Manage-bde  -computername $Computer -status C:
                $Size=$EncryptionStatus|Where-Object{$_ -like '*Size:*'}
                If ($size -ne $null)
                    {
                    $Newsize=$size.Substring(26)
                    }
                    Else 
                    {
                    $Newsize="B.N.E"
                    
                    }
                    $Conversionstatus=$EncryptionStatus|Where-Object{$_ -like '*Conversion Status:*'}
                    If ($Conversionstatus -ne $null)
                        {
                        $newConversionstatus=$Conversionstatus.Substring(26)
                        }
                        Else 
                    {
                     $newConversionstatus="B.N.E"
                    
                    }
                        $Percentage=$EncryptionStatus|Where-Object{$_ -like '*Percentage Encrypted:*'} 
                        If ($Percentage -ne $null)
                            {
                            $newpercentage=$Percentage.Substring(26)
                            }
                            Else 
                    {
                    $newpercentage="B.N.E"
                    
                    }
                            $Protectionstatus=$EncryptionStatus|Where-Object{$_ -like '*Protection Status:*'}
                            If ($Protectionstatus -ne $null)
                                {
                                $newprotectionstatus=$Protectionstatus.Substring(26)
                                }
                                Else 
                    {
                    $newprotectionstatus ="B.N.E"
                    
                    }
                         
                    $details=New-object psobject 
                    $details|Add-Member -Type NoteProperty -Name "Computer Name" -Value   $Computer
                    $details|Add-Member -Type NoteProperty -Name Size -Value $Newsize
                    $details|Add-Member -Type NoteProperty -Name "Percentage Completed" -Value $newpercentage
                    $details|Add-Member -Type NoteProperty -Name "Protection Status" -Value $newprotectionstatus
                    $details|Add-Member -Type NoteProperty -Name "Conversion Status" -Value $newConversionstatus
                    $Bitlockerforprint += $details
                    $Newsize= $null
                    $newpercentage = $null
                    $newprotectionstatus = $null
                    $newConversionstatus = $null
                   
                   }
                Catch
                    {
                    Write-Host  ($_.Exception.Message)  -ForegroundColor Red
                    }
                }
            Else
            {
            Write-Warning "Destination Host Unreachable $Computer " 
            }
    }
    $Bitlockerforprint|Select-Object "Computer Name",Size,"Percentage Completed","Conversion Status","Protection Status"|format-table -AutoSize
    $Bitlockerforprint|Select-Object "Computer Name",Size,"Percentage Completed","Conversion Status","Protection Status"|Export-Csv $LogfileName -force -encoding "unicode"  -NoClobber  -Append
    }


    • Edited by Jijo.Chacko Wednesday, October 5, 2016 6:27 AM
    Friday, July 29, 2016 6:21 AM