Skip to Content

Tag Archives: Cloud

PS script to Encrypt a Disk of a VM in Azure

Written on December 14, 2019 at 11:46 PM, by

$keyVault = Get-AzKeyVault -VaultName $keyVaultName -ResourceGroupName $rgName; $diskEncryptionKeyVaultUrl = $keyVault.VaultUri; $keyVaultResourceId = $keyVault.ResourceId; $keyEncryptionKeyUrl = (Get-AzKeyVaultKey -VaultName $keyVaultName -Name myKey).Key.kid; Set-AzVMDiskEncryptionExtension -ResourceGroupName $rgName ` -VMName “myVM” ` -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl ` -DiskEncryptionKeyVaultId $keyVaultResourceId ` -KeyEncryptionKeyUrl $keyEncryptionKeyUrl ` -KeyEncryptionKeyVaultId $keyVaultResourceId   For linux servers there might be an error as “Object reference not set to an instance […]