From bd216f46a91c4038b4b5ea9ca1d364f3e6140c7f Mon Sep 17 00:00:00 2001 From: freedbygrace Date: Fri, 24 Sep 2021 15:58:59 -0400 Subject: [PATCH] Update Decrypt-BitlockerVolume.ps1 --- Decrypt-BitlockerVolume.ps1 | 122 ++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/Decrypt-BitlockerVolume.ps1 b/Decrypt-BitlockerVolume.ps1 index 2c3a265..3dea9f9 100644 --- a/Decrypt-BitlockerVolume.ps1 +++ b/Decrypt-BitlockerVolume.ps1 @@ -1,72 +1,72 @@ -#Requires -Version 3 -Modules ('Bitlocker', 'Storage') - -<# - .SYNOPSIS - Provides the ability to remove Bitlocker disk encryption from all volumes located on fixed hard disks. Removable disk(s) will not be included. - - .DESCRIPTION - By default, only the operating system volume will be decrypted. Modify the regular expression parameter(s) to achieve the desired scenario. - Because the "Decrypt-BitlockerVolume" command is asynchronous, a Do-Until loop will be used in order to track the decrpytion process on each volume and keep the script from exiting until the decryption is completed. - - .PARAMETER DriveTypeExpression - A regular expression that correctly includes values from the "DriveType" property as seen in the example below. - +#Requires -Version 3 -Modules ('Bitlocker', 'Storage') + +<# + .SYNOPSIS + Provides the ability to remove Bitlocker disk encryption from all volumes located on fixed hard disks. Removable disk(s) will not be included. + + .DESCRIPTION + By default, only the operating system volume will be decrypted. Modify the regular expression parameter(s) to achieve the desired scenario. + Because the "Decrypt-BitlockerVolume" command is asynchronous, a Do-Until loop will be used in order to track the decrpytion process on each volume and keep the script from exiting until the decryption is completed. + + .PARAMETER DriveTypeExpression + A regular expression that correctly includes values from the "DriveType" property as seen in the example below. + DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size ----------- ------------ -------------- --------- ------------ ----------------- ------------- ---- C OS NTFS Fixed Healthy OK 164.69 GB 475.69 GB WinRE_DRV NTFS Fixed Healthy OK 503.32 MB 1000 MB - SYSTEM FAT32 Fixed Healthy OK 225.49 MB 256 MB - - .PARAMETER DriveLetterInclusionExpression - A regular expression that correctly includes the desired drive letters of encrypted volumes. By default, only the operating system volume is included. - - Examples: - All Volumes - ^[a-zA-Z]$ - Specific Volumes - ^[C]$ - Multiple Volumes - ^[E|H|K]$ - - .PARAMETER DriveLetterExclusionExpression - A regular expression that correctly excludes the desired drive letters of encrypted volumes. By default, only volumes without a drive letter are excluded. - - Examples: - Specific Volumes - ^[C]$ - Multiple Volumes - ^[E|H|K]$ - - .PARAMETER VolumeStatusExpression - A regular expression that correctly includes the bitlocker volume status of an encryptable volume. - + SYSTEM FAT32 Fixed Healthy OK 225.49 MB 256 MB + + .PARAMETER DriveLetterInclusionExpression + A regular expression that correctly includes the desired drive letters of encrypted volumes. By default, only the operating system volume is included. + + Examples: + All Volumes - ^[a-zA-Z]$ + Specific Volumes - ^[C]$ + Multiple Volumes - ^[E|H|K]$ + + .PARAMETER DriveLetterExclusionExpression + A regular expression that correctly excludes the desired drive letters of encrypted volumes. By default, only volumes without a drive letter are excluded. + + Examples: + Specific Volumes - ^[C]$ + Multiple Volumes - ^[E|H|K]$ + + .PARAMETER VolumeStatusExpression + A regular expression that correctly includes the bitlocker volume status of an encryptable volume. + VolumeType Mount CapacityGB VolumeStatus Encryption KeyProtector AutoUnlock Protection Point Percentage Enabled Status ---------- ----- ---------- ------------ ---------- ------------ ---------- ---------- OperatingSystem C: 475.69 FullyDecrypted 0 {} Off - - .PARAMETER DebugMode - Allows for the testing of this scripts functionality, but not actually perform volume decryption. - - .PARAMETER LogDir - A valid folder path. If the folder does not exist, it will be created. This parameter can also be specified by the alias "LogPath". - - .PARAMETER ContinueOnError - Ignore failures. - - .EXAMPLE - powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" - - .EXAMPLE - powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" -ScriptParameter "%ScriptParameterValue%" - - .EXAMPLE - powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" -SwitchParameter - - .NOTES + + .PARAMETER DebugMode + Allows for the testing of this scripts functionality, but not actually perform volume decryption. + + .PARAMETER LogDir + A valid folder path. If the folder does not exist, it will be created. This parameter can also be specified by the alias "LogPath". + + .PARAMETER ContinueOnError + Ignore failures. + + .EXAMPLE + powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" + + .EXAMPLE + powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" -ScriptParameter "%ScriptParameterValue%" + + .EXAMPLE + powershell.exe -ExecutionPolicy Bypass -NoProfile -NoLogo -File "%FolderPathContainingScript%\%ScriptName%.ps1" -SwitchParameter + + .NOTES The Disable-BitLocker cmdlet disables BitLocker Drive Encryption for a BitLocker volume. When you run this cmdlet, it removes all key protectors and begins decrypting the content of the volume. If the volume that hosts the operating system contains any automatic unlocking keys, the cmdlet does not proceed. You can use the Clear-BitLockerAutoUnlock cmdlet to remove all automatic unlocking keys. Then you can disable BitLocker for the volume. - For an overview of BitLocker, see BitLocker Drive Encryption Overview on TechNet. - - .LINK - https://docs.microsoft.com/en-us/powershell/module/bitlocker/disable-bitlocker?view=windowsserver2019-ps + For an overview of BitLocker, see BitLocker Drive Encryption Overview on TechNet. + + .LINK + https://docs.microsoft.com/en-us/powershell/module/bitlocker/disable-bitlocker?view=windowsserver2019-ps #> [CmdletBinding()] @@ -93,7 +93,7 @@ [Regex]$VolumeStatusExpression = "^FullyDecrypted$", [Parameter(Mandatory=$False)] - [Switch]$DebugMode = $True, + [Switch]$DebugMode, [Parameter(Mandatory=$False)] [ValidateNotNullOrEmpty()] @@ -293,8 +293,8 @@ Else $ErrorMessage = "[Error Message: $($ExceptionMessage)][ScriptName: $($_.InvocationInfo.ScriptName)][Line Number: $($_.InvocationInfo.ScriptLineNumber)][Line Position: $($_.InvocationInfo.OffsetInLine)][Code: $($_.InvocationInfo.Line.Trim())]`r`n" Write-Error -Message "$($ErrorMessage)" - } - + } + #Log any useful information [String]$CmdletName = $MyInvocation.MyCommand.Name @@ -788,4 +788,4 @@ Else Stop-Transcript -Verbose } } - } \ No newline at end of file + }