Instantly share code, notes, and snippets.

Embed
What would you like to do?
invoke-webrequest https://raw.githubusercontent.com/Azure/azure-powershell/master/src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1 -Outfile 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