Backup-BitLockerKeyProtector
Windows: Backs up a BitLocker key protector to AD DS or AAD
#Requires -Version 5.1
#Requires -Modules BitLocker
[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]
[string]$MountPoint,
[Parameter(Mandatory = $true)]
[string]$KeyProtectorId,
[string]$ComputerName = $env:COMPUTERNAME,
[pscredential]$Credential
)
Process {
try {
$scriptBlock = {
Param($Drive, $Id)
Backup-BitLockerKeyProtector -MountPoint $Drive -KeyProtectorId $Id -ErrorAction Stop
}
if ($ComputerName -ne $env:COMPUTERNAME) {
$invokeParams = @{
'ComputerName' = $ComputerName
'ScriptBlock' = $scriptBlock
'ArgumentList' = @($MountPoint, $KeyProtectorId)
'ErrorAction' = 'Stop'
}
if ($null -ne $Credential) {
$invokeParams.Add('Credential', $Credential)
}
Invoke-Command @invokeParams
}
else {
&$scriptBlock -Drive $MountPoint -Id $KeyProtectorId
}
$output = [PSCustomObject]@{
MountPoint = $MountPoint
KeyProtectorId = $KeyProtectorId
Status = "BackupInitiated"
ComputerName = $ComputerName
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $output
}
catch {
throw
}
}Specifies the drive letter or mount point (e.g., "C:").
Specifies the unique ID of the key protector to back up.
Specifies the name of the target computer. Defaults to the local computer.
Specifies a PSCredential object for remote connection.