Skip to content

Instantly share code, notes, and snippets.

@PixelRobots
Last active January 30, 2019 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PixelRobots/58ad2e3aabc8ff631b10f71bc87d1cc0 to your computer and use it in GitHub Desktop.
Save PixelRobots/58ad2e3aabc8ff631b10f71bc87d1cc0 to your computer and use it in GitHub Desktop.
invoke-webrequest https://raw.githubusercontent.com/Azure/azure-powershell/master/src/Compute/Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1
Login-AzureRmAccount
Get-AzureRmSubscription
./AzureDiskEncryptionPreRequisiteSetup.ps1 -SubscriptionID "e03cfa2a-c5a9-4f4e-afbd-462c181f761e" -ResourceGroupName "PixelRobots" -KeyVaultName "PixelVMEncrypt" -location "East US 2" -AADAppName "PixelVMEncrypt"
Set-AzureRmKeyVaultAccessPolicy -VaultName 'PixelVMEncrypt' -ResourceGroupName 'PixelRobots' -EnabledForDiskEncryption
$rgName = 'PixelRobots';
$vmName = 'VM1';
$KeyVaultName = 'PixelVMEncrypt';
$KeyVault = Get-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName $rgname;
$diskEncryptionKeyVaultUrl = $KeyVault.VaultUri;
$KeyVaultResourceId = $KeyVault.ResourceId;
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId
Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName 'PixelRobots' -VMName 'VM1'
Disable-AzureRmVMDiskEncryption -ResourceGroupName 'PixelRobots' -VMName 'VM1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment