{"id":5931,"date":"2015-05-26T00:01:00","date_gmt":"2015-05-26T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/05\/26\/powershell-and-bitlocker-part-2\/"},"modified":"2019-02-18T09:47:46","modified_gmt":"2019-02-18T16:47:46","slug":"powershell-and-bitlocker-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-bitlocker-part-2\/","title":{"rendered":"PowerShell and BitLocker: Part 2"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Guest blogger, Stephane van Gulick, continues his series about using Windows PowerShell and BitLocker together.<\/span><\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Welcome back Stephane van Gulick for the final part of his two-part series. Be sure you read <a href=\"https:\/\/devblogs.microsoft.com\/scripting\/powershell-and-bitlocker-part-1\/\" target=\"_blank\">PowerShell and BitLocker: Part 1<\/a> first.<\/p>\n<h2>Encryption operations<\/h2>\n<p>A lot of the following script examples come from a function I wrote called <a href=\"http:\/\/powershelldistrict.com\/powershell-bitlocker-encryption-tool-sak\/\" target=\"_blank\">BitLockerSAK<\/a>. It is a tool written in Windows PowerShell that makes BitLocker tasks easier to automate.<\/p>\n<p>Finally, we arrive at the interesting part: the encryption of the drive. Don&rsquo;t get me wrong&mdash;the Trusted Platform Module (TPM) operations are extremely important in the process of automating the drive encryption. Without these steps, the drive encryption might not even happen. But this is where I had the most fun in the scripting process.<\/p>\n<p>Are you sitting comfortably? You might want to get a refill of coffee before we hit it. Ready? All right&#8230;let&rsquo;s go!<\/p>\n<p>Everything that relates to the proper encryption of the drive and that needs to be automated resides in the WMI (CIM) repository. It lies in the same <b>Root\\cimv2\\Security\\ <\/b>namespace hierarchy as the <b>Win32_TPM<\/b>. But this time we will dive into the <b>Win32_EncryptableVolume<\/b> class<i>.<\/i><\/p>\n<p>The <b>Win32_EncryptableVolume<\/b> class contains an instance for each of the volumes that are present on the computer (for example, hard drives and USB keys).<\/p>\n<p>We can look into it by using the following command, and because we generally want to encrypt the system drive, we will filter on drive C.<\/p>\n<p>Using <b>Get-CimInstance<\/b> will look like this (the results are shown in green in the following image):<\/p>\n<p style=\"margin-left:30px\">$CIMVolumeC = Get-CimInstance -namespace &quot;Root\\cimv2\\security\\MicrosoftVolumeEncryption&quot; -ClassName &quot;Win32_Encryptablevolume&quot; &#8211;<\/p>\n<p>Or we can use <b>Get-WmiObject <\/b>as follows for retrocompatibility (shown in red in the following image):<\/p>\n<p style=\"margin-left:30px\">$WMIVolumeC= Get-WmiObject -namespace &quot;Root\\cimv2\\security\\MicrosoftVolumeEncryption&quot; -ClassName &quot;Win32_Encryptablevolume&quot; -filter &quot;DriveLetter = &#039;C:&#039;&quot;<\/p>\n<p>As you can see, these two commands return (almost) the same results:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-1.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The only difference is that <b>Get-WMIObject<\/b> returns the instance and the system properties (they start with the double underscore &ldquo;<b>__<\/b>&rdquo;).<\/p>\n<p>Let&rsquo;s look at the properties and methods we have access to through the two methods.<\/p>\n<p><b>Get-CIMInstance<\/b> returns the following list:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-2.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p><b>Get-WMIObject<\/b> returns a bunch more methods&mdash;there are so many that we cannot see them all on this screenshot:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-3.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-3.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The CIM option returns only 18 results when piped to <b>Get-Member<\/b>:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-4.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-4.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>But good old <b>Get-WMIObject<\/b> returns 84 results:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-5.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-5.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Now that we have seen the methods that are available, we can start to work with them.<\/p>\n<h2>Key protectors<\/h2>\n<p>Prior to launching the encryption of a specific volume, we need to set a key protector. A key protector will protect the volume encryption key, which will protect the volume that has just been encrypted.<\/p>\n<p>We can find all the key protectors that can be set by using the following code:<\/p>\n<p style=\"margin-left:30px\">$EncryptionData = Get-WMIObject -Namespace &quot;Root\\cimv2\\security\\MicrosoftVolumeEncryption&quot; &ndash;classname &quot;Win32_EncryptableVolume&quot; -Filter &quot;DriveLetter = &#039;c:&#039;&quot;<\/p>\n<p>We have a few methods available as shown in the following screenshot:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-6.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-6.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Those I have worked with the most are:<\/p>\n<ul>\n<li>ProtectKeyWithTPM<\/li>\n<li>ProtectKeyWithTPMAndPIN<\/li>\n<li>ProtectKeyNumericalPassword<\/li>\n<\/ul>\n<p>Theoretically, we could allow any key protector on any computer. But this is something you want to control in your environment. This can be easily achieved by using a Group Policy Object (GPO).<\/p>\n<p>Each key protector will deliver another encryption experience and it will need some custom scripting to make it work in your environment.<\/p>\n<p>We will not go into the details of each because that would make this post even longer that what it already is. But each of the previous methods are documented on MSDN, so you can find everything that you need there.<\/p>\n<h3>Protection key IDs and types<\/h3>\n<p>We list the key protectors that are currently on one computer by using <b>GetKeyProtectors<\/b> and <b>getKeyProtectorType<\/b> from the <b>Win32_Encryptable<\/b> class. Here is the code from my BitLockerSAK function:<\/p>\n<p style=\"margin-left:30px\">$BitLocker = Get-WmiObject -Namespace &quot;Root\\cimv2\\Security\\MicrosoftVolumeEncryption&quot; -Class &quot;Win32_EncryptableVolume&quot; -Filter &quot;DriveLetter = &#039;$DriveLetter&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ProtectorIds = $BitLocker.GetKeyProtectors(&quot;0&quot;).volumekeyprotectorID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $return = @()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ($ProtectorID in $ProtectorIds){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $KeyProtectorType = $BitLocker.GetKeyProtectorType($ProtectorID).KeyProtectorType<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $keyType = &quot;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch($KeyProtectorType){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;0&quot;{$Keytype = &quot;Unknown or other protector type&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;1&quot;{$Keytype = &quot;Trusted Platform Module (TPM)&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;2&quot;{$Keytype = &quot;External key&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;3&quot;{$Keytype = &quot;Numerical password&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;4&quot;{$Keytype = &quot;TPM And PIN&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;5&quot;{$Keytype = &quot;TPM And Startup Key&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;6&quot;{$Keytype = &quot;TPM And PIN And Startup Key&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;7&quot;{$Keytype = &quot;Public Key&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;8&quot;{$Keytype = &quot;Passphrase&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;9&quot;{$Keytype = &quot;TPM Certificate&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;10&quot;{$Keytype = &quot;CryptoAPI Next Generation (CNG) Protector&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }#endSwitch<\/p>\n<p style=\"margin-left:30px\">&nbsp;$Properties = @{&quot;KeyProtectorID&quot;=$ProtectorID;&quot;KeyProtectorType&quot;=$Keytype}<\/p>\n<p style=\"margin-left:30px\">&nbsp; $Return += New-Object -TypeName psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }#EndForeach<\/p>\n<p style=\"margin-left:30px\">Return $Return<\/p>\n<p>This enumerates the all the existing key protectors. Based on their IDs, it will fetch their type, put it in a custom object, and return the information through the variable <b>$return<\/b>.<\/p>\n<p>You will have something similar to this:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-7.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-7.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Those I have seen the most are:<\/p>\n<ul>\n<li>Numerical Password (return value 3)<\/li>\n<li>TPM and PIN (return value 4)<\/li>\n<\/ul>\n<h2>BitLocker Drive Encryption operations<\/h2>\n<p>Finally, we come to the part about BitLocker Drive Encryption operations&#8230;<\/p>\n<p>There is one main WMI class that hosts all the encryption methods and properties of all of your drives: the <b>Win32_EncryptableVolume<\/b>. You will find this class in the <b>Root\\cimv2\\security\\MicrosoftVolumeEncryption<\/b> namespace.<\/p>\n<h3>Global protection state<\/h3>\n<p>Prior to any encryption operations, you most likely would want to verify which state the drive is in. If it is already 100% encrypted, you will save you some time. We can get that information by using the following &nbsp;code:<\/p>\n<p style=\"margin-left:30px\">$ProtectionState = Get-WmiObject -Namespace ROOT\\CIMV2\\Security\\Microsoftvolumeencryption -Class Win32_encryptablevolume -Filter &quot;DriveLetter = &#039;c:&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch ($ProtectionState.GetProtectionStatus().protectionStatus){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;0&quot;){$return = &quot;Unprotected&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;1&quot;){$return = &quot;Protected&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2&quot;){$return = &quot;Uknowned&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default {$return = &quot;NoReturn&quot;}<\/p>\n<p style=\"margin-left:30px\">}<\/p>\n<p style=\"margin-left:30px\">return $return<\/p>\n<p>We get a value of either 0, which means the drive is unprotected or 1, which means the drive is protected.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-8.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-8.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>This is a first step. If the drive is protected, you can quit the whole script logic because this means that your drive is currently 100% encrypted, and it is ready for the wild, wild west.<\/p>\n<h3>Encryption state and encryption percentage<\/h3>\n<p>If you want the see the current encryption state of your drive, you can use the following code:<\/p>\n<p style=\"margin-left:30px\">$EncryptionData= Get-WmiObject -Namespace ROOT\\CIMV2\\Security\\Microsoftvolumeencryption -Class Win32_encryptablevolume -Filter &quot;DriveLetter = &#039;c:&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $protectionState = $EncryptionData.GetConversionStatus()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $CurrentEncryptionProgress = $protectionState.EncryptionPercentage<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch ($ProtectionState.Conversionstatus){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;0&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=&#039;FullyDecrypted&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;1&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Properties = @{&#039;EncryptionState&#039;=&#039;FullyEncrypted&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;2&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=&#039;EncryptionInProgress&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;3&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=&#039;DecryptionInProgress&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;4&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=&#039;EncryptionPaused&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;5&quot; {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=&#039;DecryptionPaused&#039;;&#039;CurrentEncryptionProgress&#039;=$CurrentEncryptionProgress}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-verbose &quot;Couldn&#039;t retrieve an encryption state.&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;EncryptionState&#039;=$false;&#039;CurrentEncryptionProgress&#039;=$false}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">return $return<\/p>\n<p>The current encryption state and the current percentage of encryption of the current drive will be returned. If I launch this part of the code on my computer with elevated rights, the following results are returned:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-9.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-9.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p><b>Note<\/b>&nbsp; In the case of decryption, the percentage represents the amount of encrypted space.<\/p>\n<p>The following Visio flow chart helps us see a global overview. It shows the action and the methods that are related to these actions.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-10.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-10.png\" alt=\"Image of flow chart\" title=\"Image of flow chart\" \/><\/a><\/p>\n<h2>Encryption<\/h2>\n<p>Now that we have identified the current state of the drive, we want to start the encryption. At this state, you should already have a protection key.<\/p>\n<p>If we take a peek in the MSDN documentation, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa376467(v=vs.85).aspx\" target=\"_blank\">ProtectKeyWithNumericalPassword<\/a>, we see that the <b>ProtectKeyWithNumericalPassword<\/b> method has two parameters as input <b>[IN]<\/b>, and one as output <b>[OUT]<\/b>. But both of the input parameters are optional <b>[Optional]<\/b>. This means that we can actually call this method without passing any parameters.<\/p>\n<p><b>Note<\/b>&nbsp; The following code will only work if you have set a GPO that allows drive protection by using TPM and PIN.<\/p>\n<p style=\"margin-left:30px\">$pin = 123456&nbsp;<\/p>\n<p style=\"margin-left:30px\">$ProtectionState = Get-WmiObject -Namespace ROOT\\CIMV2\\Security\\Microsoftvolumeencryption -Class Win32_encryptablevolume -Filter &quot;DriveLetter = &#039;$DriveLetter&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; write-verbose &quot;Launching drive encryption.&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ProtectorKey = $protectionState.ProtectKeyWithTPMAndPIN(&quot;ProtectKeyWithTPMAndPIN&quot;,&quot;&quot;,$pin)<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start-Sleep -Seconds 3<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$NumericalPasswordReturn = $protectionState.ProtectKeyWithNumericalPassword()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = $protectionState.Encrypt()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $returnCode = $return.returnvalue<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch ($ReturnCode) {<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;0&quot;){$message = &quot;Operation successfully started.&quot;}<\/p>\n<p style=\"margin-left:30px;text-align:justify\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2147942487&quot;) {$message = &quot;The EncryptionMethod parameter is provided but is not within the known range or does not match the current Group Policy setting.&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2150694958&quot;) {$message = &quot;No encryption key exists for the volume&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2150694957&quot;) {$message = &quot;The provided encryption method does not match that of the partially or fully encrypted volume.&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2150694942&quot;) {$message = &quot;The volume cannot be encrypted because this computer is configured to be part of a server cluster.&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;2150694956&quot;) {$message = &quot;No key protectors of the type Numerical Password are specified. The Group Policy requires a backup of recovery information to Active Directory Domain Services&quot;}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default{<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $message = &quot;An unknown status was returned by the Encryption action.&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Properties = @{&#039;ReturnCode&#039;=$ReturnCode;&#039;ErrorMessage&#039;=$message}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Return = New-Object psobject -Property $Properties<\/p>\n<p style=\"margin-left:30px\">return $return<\/p>\n<p>As you can see, we use following two methods to encrypt our drive:<\/p>\n<ul>\n<li>ProtectKeyWithTPMandPIN<\/li>\n<li>ProtectKeyWithNumericalPassword<\/li>\n<\/ul>\n<p>To protect our volume, we will use the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/aa376468(v=vs.85).aspx\" target=\"_blank\">ProtectKeyWithTPMAndPIN<\/a> method. For this method, there are several parameters that we could pass, but only <b>PIN<\/b> is a required parameter.<\/p>\n<p>According to the documentation, <b>PIN<\/b> accepts a user-specified personal identification string as input. This string must consist of a sequence of 4 to 20 digits or, if the &quot;Allow enhanced PINs for startup&quot; Group Policy is enabled, 4 to 20 letters, symbols, spaces, or numbers.<\/p>\n<p>If a 0 is returned (operation successfully started), you can call the previous code and see how the encryption percentage progresses through the time.<\/p>\n<h3>Pause the encryption<\/h3>\n<p>If at any time, you want to pause the encryption, you can use the following code:<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $BitLocker = Get-WmiObject -Namespace &quot;Root\\cimv2\\Security\\MicrosoftVolumeEncryption&quot; -Class &quot;Win32_EncryptableVolume&quot; -Filter &quot;DriveLetter = &#039;$DriveLetter&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ReturnCode = $BitLocker.PauseConversion()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch ($ReturnCode.ReturnValue){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;0&quot;{$Return = &quot;Paused sucessfully.&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;2150694912&quot;{$Return = &quot;The volume is locked.&quot;;Break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default {$Return = &quot;Uknown return code.&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">return $return<\/p>\n<p><b>Note<\/b>&nbsp; To continue the encryption from where it was paused, simply use previous encryption code to call the <b>encrypt()<\/b> method again.<\/p>\n<p>The drive encryption logic is summarized in the following Visio flow chart. It shows the actions and the methods that are related to these actions.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-11.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-11.png\" alt=\"Image of flow chart\" title=\"Image of flow chart\" \/><\/a><\/p>\n<h3>Decryption<\/h3>\n<p>In some cases, you might want or need to decrypt a drive. Again, this can be done through the <b>Win32_EncryptableVolume<\/b> WMI class with the following code:<\/p>\n<p style=\"margin-left:30px\">$BitLocker = Get-WmiObject -Namespace &quot;Root\\cimv2\\Security\\MicrosoftVolumeEncryption&quot; -Class &quot;Win32_EncryptableVolume&quot; -Filter &quot;DriveLetter = &#039;c:&#039;&quot;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ReturnCode = $BitLocker.Decrypt()<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch ($ReturnCode.ReturnValue){<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;0&quot;{$Return = &quot;Uncryption started successfully.&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;2150694912&quot;{$Return = &quot;The volume is locked.&quot;;Break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;2150694953&quot; {$Return = &quot;This volume cannot be decrypted because keys used to automatically unlock data volumes are available.&quot;;Break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default {$Return = &quot;Uknown return code.&quot;;break}<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p style=\"margin-left:30px\">return $return<\/p>\n<p>If the code is launched, it will start the decryption of drive C.<\/p>\n<p>If you launch the encryption state code again, you will see that the decryption starts and the <b>CurrentEncryptionProgress<\/b> percentage gets closer to zero each time you launch it.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-13.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-13.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The methodology must be familiar to most of you by now. If we combine the previous code examples, we can build a logic similar to the following quite easily by using the <b>Decrypt()<\/b> method.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-14.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-14.png\" alt=\"Image of flow chart\" title=\"Image of flow chart\" \/><\/a><\/p>\n<h2>Global encryption logic<\/h2>\n<p>I have presented a lot of code, and all of these single tasks need to be done in a specific order. I have summarized all the BitLocker encryption logic in the following Visio flow chart:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-15.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-5-26-15-15.png\" alt=\"Image of flow chart\" title=\"Image of flow chart\" \/><\/a><\/p>\n<p>If the encryption involves a TPM, the TPM also need to be activated; and therefore, some specific TPM actions need to be done. (Those details are discussed in the first post of this series.)<\/p>\n<h2>BitLockerSAK<\/h2>\n<p>The BitLocker Swiss Army Knife (BitLockerSAK) is a project I started a while ago. It started with the need to automate TPM and BitLocker encryption for one of my clients. This client didn&rsquo;t have Windows PowerShell&nbsp;3.0 deployed&mdash;thus no BitLocker or CIM cmdlets.<\/p>\n<p>After repetitively executing <b>Get-WMIObject<\/b> calls, I thought I would simplify the complete process and combine all of this in one unique tool that would have the look and feel of the well-known <b>Manage-bde.exe<\/b>. I wrote version 1.0 in a weekend and posted it shortly after.<b><\/b><\/p>\n<p>BitLockerSAK makes TPM and drive encryption operations through Windows PowerShell much easier than calling the different WMI methods directly. It has additional logic that will save a lot of time for those who need to script BitLocker or TPM tasks. I have used it in complex encryption scripts and in Configuration Manager configuration items to retrieve non encrypted computers, and remediate the non-compliant ones.<\/p>\n<p>The following tables might look similar, but I have simplified them (especially the WMI Method section) to help you identify how to execute which encryption or TPM task according to which tool you are using.<\/p>\n<h3>TPM operations equivalence<\/h3>\n<p>The following table lists the most common TPM WMI methods (based on <b>Win32_TPM<\/b>) and their BitLockerSAK equivalents.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p>&nbsp;<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p><strong>WMIMethod<\/strong><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p><strong>BitLockerSAK<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Enabled<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.IsEnabled().isenabled<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -isTPMEnabled<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Activated<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.IsActivated().isactivated<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -isTPMActivated<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Owned<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.IsOwned().Isowned<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -isTPMOwned<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Take TPM OwnerShip<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.ClearTpm + .TakeOwnerShip<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -TakeTPMOwnership<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Encryption operations equivalences<\/h3>\n<p>The following table lists the most common encryption WMI methods (based on <b>Win32_EncryptableVolume<\/b>) and their BitLockerSAK equivalents.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p>&nbsp;<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p><b>WMIMethod<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p><b>BitLockerSAK<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Get protection status<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.protectionStatus + code to convert return code.<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -GetProtectionStatus<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Get encryption state<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.GetConversionStatus() + encryptionpercentage<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -GetEncryptionState<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Get key protector type<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.GetKeyProtectorType(&ldquo;ID&rdquo;)<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &#8211; GetKeyProtectorTypeAndID<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Get key protector ID<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.GetKeyProtectors(). volumekeyprotector<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &#8211; GetKeyProtectorTypeAndID<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Delete key protector<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.DeleteKeyProtectors()<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &ndash;DeleteKeyProtector &ndash;protectorID &ldquo;ID&rdquo;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Encrypt drive<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">Specify the protector type +.Encrypt()<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &ndash;encrypt &ndash;pin &ldquo;123456&rdquo;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\"><b>Pause encryption<\/b><\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">.PauseConversion()<\/p>\n<\/td>\n<td width=\"213\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -PauseEncryption<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Windows Powershell cmdlets in Windows&nbsp;8.1<\/h2>\n<p>Windows 8.1 brought a lot of new features, but one thing that was missing for some time were official Windows PowerShell cmdlets for TPM and encryption management. Luckily, Windows 8.1 came with Windows PowerShell&nbsp;4.0 and a new set of cmdlets for managing BitLocker operations.<\/p>\n<h3>BitLocker cmdlets<\/h3>\n<p>The following cmdlets are provided in Windows&nbsp;8.1 for BitLocker operations:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8311.hsg-5-26-15-16.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8311.hsg-5-26-15-16.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<h3>TPM cmdlets<\/h3>\n<p>There are 11 cmdlets for the TPM operations, and they are available in a module called <b>TrustedPlatformModule<\/b>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1586.hsg-5-26-15-17.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1586.hsg-5-26-15-17.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>I have updated the equivalence tables with these new cmdlets to help finding the information easier.<\/p>\n<h4>BitLocker equivalences<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p>&nbsp;<\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p><b>WMIMethod<\/b><\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\"><b>BitLockerSAK<\/b><\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\"><b>Windows 8.1 cmdlets<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Get protection status<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.protectionStatus + code to convert return code.<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">Get-BitLockerVolume<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Get encryption state<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.GetConversionStatus() + encryptionpercentage<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">(Get-BitLockerVolume).EncryptionPercentage<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Get key protector type<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.GetKeyProtectorType(&ldquo;ID&rdquo;)<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<p class=\"BullList\">&nbsp;<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">(Get-BitLockerVolume).keyprotector<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Get key protector ID<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.GetKeyProtectors(). volumekeyprotector<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<p class=\"BullList\">&nbsp;<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">(Get-BitLockerVolume).keyprotector[0].KeyProtectorID<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Delete key protector<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.DeleteKeyProtectors()<\/p>\n<p class=\"BullList\">&nbsp;<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &ndash;DeleteKeyProtector &ndash;protectorID &ldquo;ID&rdquo;<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">Remove-BitLockerKeyprotector<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Encrypt drive<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">Specify the protector type +<\/p>\n<p class=\"BullList\">.Encrypt()<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK &ndash;encrypt &ndash;pin &ldquo;123456&rdquo;<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">Enable-BitLocker<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"147\" valign=\"top\">\n<p class=\"BullList\"><b>Pause encryption<\/b><\/p>\n<\/td>\n<td width=\"158\" valign=\"top\">\n<p class=\"BullList\">.PauseConversion()<\/p>\n<\/td>\n<td width=\"175\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -PauseEncryption<\/p>\n<\/td>\n<td width=\"159\" valign=\"top\">\n<p class=\"BullList\">Suspend-BitLocker<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>TPM sheet<\/h4>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td width=\"160\" valign=\"top\">\n<p>&nbsp;<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p><b>WMIMethod<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p><b>BitLockerSAK<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p><b>Windows 8.1 Cmdlets<\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Enabled<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">.IsEnabled().isenabled<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">Get-TPM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Activated<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">.IsActivated().isactivated<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">Get-TPM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\"><b>TPM Owned<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">.IsOwned().Isowned<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">Get-TPM<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\"><b>Take TPM OwnerShip<\/b><\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">.ClearTpm + .TakeOwnerShip<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">BitLockerSAK -TakeTPMOwnership<\/p>\n<\/td>\n<td width=\"160\" valign=\"top\">\n<p class=\"BullList\">Initialize-Tpm -AllowClear<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here is my contact information:<\/p>\n<p>Website:&nbsp;<a href=\"http:\/\/www.powershelldistrict.com\/\" target=\"_blank\">PowerShell District<\/a><br \/> Twitter:&nbsp;<a href=\"https:\/\/twitter.com\/Stephanevg\" target=\"_blank\">@Stephanevg<\/a><br \/> Linked-In:&nbsp;<a href=\"http:\/\/www.linkedin.com\/pub\/st%C3%A9phane-van-gulick\/38\/247\/147\" target=\"_blank\">St&eacute;phane van Gulick<\/a><\/p>\n<p>~Stephane<\/p>\n<p>Thank you again, Stephane, for sharing your time and knowledge. This has been an awesome series, and one that is timely and important.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Guest blogger, Stephane van Gulick, continues his series about using Windows PowerShell and BitLocker together. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back Stephane van Gulick for the final part of his two-part series. Be sure you read PowerShell and BitLocker: Part 1 first. Encryption operations A lot of the following script examples [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[587,56,3,63,588,45],"class_list":["post-5931","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-bitlocker","tag-guest-blogger","tag-scripting-guy","tag-security","tag-stephane-van-gulick","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Guest blogger, Stephane van Gulick, continues his series about using Windows PowerShell and BitLocker together. Microsoft Scripting Guy, Ed Wilson, is here. Welcome back Stephane van Gulick for the final part of his two-part series. Be sure you read PowerShell and BitLocker: Part 1 first. Encryption operations A lot of the following script examples [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/5931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=5931"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/5931\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=5931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=5931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=5931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}