Export-Bitlocker.ps1

something exciting

Some information about the exciting thing

Table of contents generated with markdown-toc


Script

[CmdletBinding()]
param(
    [Parameter(Mandatory = $True,
        ValueFromPipeline = $True,
        ValueFromPipelineByPropertyName = $True,
        HelpMessage = "Please enter the ComputerName or Pipe in from another command.")]
    [Alias('Hostname', 'cn')]
    [string[]]$ComputerName
)

BEGIN {

}

PROCESS {
    foreach ($Computer in $ComputerName) {
        try {
            $TPMKey = Get-BitLockerVolume
            $TMPID = $TPMKey | Select-Object KeyProtector -ExpandProperty KeyProtector

            $Keyproperties = @{ComputerName = $TPMKey.ComputerName
                MountPoint                  = $TPMKey.MountPoint
                CapacityGB                  = $TPMKey.CapacityGB
            }
            $TMPID = $TPMKey | Select-Object KeyProtector -ExpandProperty KeyProtector
            $IDproperties = @{KeyProtectorType = $TMPID.KeyProtectorType
                KeyProtectorId                 = $TMPID.KeyProtectorId
                RecoveryPassword               = $TMPID.RecoveryPassword
            }
        }
        catch {
            Write-Verbose "Couldn't connect to $Computer"
            $Keyproperties = @{ComputerName = $TPMKey.ComputerName
                MountPoint                  = $TPMKey.MountPoint
                CapacityGB                  = $TPMKey.CapacityGB
            }
            $IDproperties = @{KeyProtectorType = $TMPID.KeyProtectorType
                KeyProtectorId                 = $TMPID.KeyProtectorId
                RecoveryPassword               = $TMPID.RecoveryPassword
            }
        }
        finally {
            $Keyobj = New-Object -TypeName PSObject -Property $Keyproperties
            Write-Output $Keyobj
            $IDobj = New-Object -TypeName PSObject -Property $IDproperties
            Write-Output $IDobj

        }
    }
}
END {

}

Back to Top


Download

Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.

Issue


Back to Top