Q. How can I read the content of the Windows 2016 VMCX virtual machine configuration file?
A. Windows Server 2016 Hyper-V changes the virtual machine configuration file to binary, which provides additional resiliency from corruption and dissuades people from manually trying to edit the file. If you wish to view the configuration within a VMCX file, it's not possible to just type out the file since it is now binary. The best method I have found is to create a temporary object that contains a copy of the configuration in the VMCX file. It is then possible to view all the data from within the temporary object that is a copy of the VMCX configuration. For example:
$tempVM = (Compare-VM -Copy -Path .\yourvmcxfile.vmcx -GenerateNewID).VM
You can example all the key properties using:
$tempVM | select *
It is also possible to view specific collections that are part of the object such as network adapters and disks. For example:
$tempVM.NetworkAdapters
$tempVM.HardDrives
$tempVM.FibreChannelHostBusAdapters
If you type $tempVM. and press tab, PowerShell will show all the options available to you.
Below is an example of this in action.
PS C:\> $tempVM = (Compare-VM -Copy -Path .\DF8560F4-4A6A-49B7-8E87-3B54D4101B40.vmcx -GenerateNewID).VM
PS C:\> $tempVM
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status
---- ----- ----------- ----------------- ------ ------
savdaldemo01 Off 0 0 Operating normally
PS C:\> $tempVM | select *
VMName : savdaldemo01
VMId : 904f432b-d545-4a9f-9560-8dc9145a56ae
Id : 904f432b-d545-4a9f-9560-8dc9145a56ae
Name : savdaldemo01
State : Off
IntegrationServicesState :
OperationalStatus : {Ok}
PrimaryOperationalStatus : Ok
SecondaryOperationalStatus :
StatusDescriptions : {Operating normally}
PrimaryStatusDescription : Operating normally
SecondaryStatusDescription :
Status : Operating normally
Heartbeat :
ReplicationState :
ReplicationHealth :
ReplicationMode :
CPUUsage : 0
MemoryAssigned : 0
MemoryDemand : 0
MemoryStatus :
SmartPagingFileInUse :
Uptime :
IntegrationServicesVersion :
ResourceMeteringEnabled : False
AutomaticCriticalErrorAction : Pause
AutomaticCriticalErrorActionTimeout : 30
ConfigurationLocation : C:\Virtuals
SnapshotFileLocation : C:\Virtuals
CheckpointType : Production
AutomaticStartAction : StartIfRunning
AutomaticStopAction : Save
AutomaticStartDelay : 0
SmartPagingFilePath : C:\Virtuals
NumaAligned :
NumaNodesCount :
NumaSocketCount :
Key : Microsoft.HyperV.PowerShell.VirtualMachineObjectKey
IsDeleted : False
ComputerName : SAVDALHVFX
Version : 6.0
Notes : #CLUSTER-INVARIANT#:{94838b88-2846-4e3d-9caa-850fb785fe3b}
Generation : 2
Path : C:\Virtuals
CreationTime : 8/5/2015 12:35:11 PM
IsClustered : False
SizeOfSystemFiles : 0
ParentSnapshotId :
ParentSnapshotName :
MemoryStartup : 2147483648
DynamicMemoryEnabled : False
MemoryMinimum : 536870912
MemoryMaximum : 1099511627776
ProcessorCount : 1
RemoteFxAdapter :
NetworkAdapters : {Network Adapter}
FibreChannelHostBusAdapters : {}
ComPort1 : Microsoft.HyperV.PowerShell.VMComPort
ComPort2 : Microsoft.HyperV.PowerShell.VMComPort
FloppyDrive :
DVDDrives : {}
HardDrives : {Hard Drive on SCSI controller number 0 at location 0}
VMIntegrationService : {Time Synchronization, Heartbeat, Key-Value Pair Exchange,
Shutdown...}
PS C:\> $tempVM.NetworkAdapters
Name IsManagementOs VMName SwitchName MacAddress Status IPAddresses
---- -------------- ------ ---------- ---------- ------ -----------
Network Adapter False savdaldemo01 External Switch 000000000000