Created
February 6, 2021 01:05
-
-
Save JaekelEDV/6f7c37c46fca24ea923be9e0cc21a9d2 to your computer and use it in GitHub Desktop.
New-BitLockerVhdx.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#New-BitLockerVhdx.ps1, create a vhdx, enable BitLocker. | |
#->Share encrypted data between machines (mount, attach to VMs) and peers (vhdx->Stick) | |
#All with Windows standard tools. | |
throw "Nope. This is no script, just a bunch of cmdlets." | |
#Create a new vhdx | |
New-VHD -Path .\sec.vhdx -SizeBytes 1GB -Fixed | |
#Mount the vhdx | |
Mount-VHD -Path .\sec.vhdx | |
#Initialize,Partition,FS | |
Get-Disk -FriendlyName 'Msft Virtual Disk' | | |
Initialize-Disk -PartitionStyle GPT | | |
New-Partition -UseMaximumSize -DriveLetter 'S' | | |
Format-Volume -FileSystem NTFS -NewFileSystemLabel 'SEC' | |
#Enable-Bitlocker | |
$Pass = 'Password' | ConvertTo-SecureString -AsPlainText -Force | |
$BitLockerParams = @{ | |
MountPoint = "S:" | |
EncryptionMethod = 'Aes256' | |
SkipHardwareTest = $true | |
PasswordProtector = $true | |
Password = $Pass | |
} | |
Enable-BitLocker @BitLockerParams | |
#You might want to add other protector methods with Add-BitLockerKeyProtector. | |
#Check: Dismount, mount fails, first unlock | |
Dismount-VHD -Path .\sec.vhdx | |
Mount-VHD -Path .\sec.vhdx | |
Unlock-BitLocker -MountPoint "S:" -Password $Pass | |
#Put the mount (and unlock, then think of how to store the password) commands in a startup/logon script. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment