vCenter Server
vSphere ESX
If the virtual machine key is not available, a vCenter Server alarm notifies you and the state of the virtual machine displays as invalid. The virtual machine cannot power on. If the virtual machine key is available, but a key for an encrypted disk is not available, the virtual machine state does not display as invalid. However, the virtual machine cannot power on and the following error results:
The disk [/path/to/the/disk.vmdk] is encrypted and a required key was not found.
Updated script (updates bolded) to query all VMs and get power state.
vm-to-kms-association_2.ps1
#Updated to query all VMs and include PowerState.
$cryptoManager = Get-View $global:DefaultVIServer.ExtensionData.Content.CryptoManager
$kmsServers = @{}
foreach ($i in $cryptoManager.KmipServers) {
if($i.ManagementType -eq "nativeProvider") {
$type = "NKP"
} else { $type = "SKP"}
$kmsServers.add($i.ClusterId.id,$type)
}
$vms = Get-View -ViewType VirtualMachine -Property Name, summary, Config
$kmsVms = @()
foreach ($vm in $vms | Sort-Object -Property Name) {
#if($vm.Config.KeyId -ne $null) {
$tmp = [pscustomobject]@{
Name = $vm.Name
PowerState=$vm.summary.runtime.powerstate
KMS = $vm.Config.KeyId.ProviderId.id
KeyId = $vm.Config.KeyId.keyId
}
$kmsVms+=$tmp
#}
}
Write-Host -ForegroundColor Cyan "`n==== vCenter Key Providers ===="
$kmsServers
Write-Host -ForegroundColor yellow "`n==== VM Key Provider Mapping ===="
$kmsVms | ft