When trying to run the Optimize Hosts wizard within SCVMM 2012 R2 I received the error “Dynamic Optimization Cannot Be Performed At This Time” and “Object reference not set to an instance of an object”.
The Application Event Log on the SCVMM server contained a Windows Error Reporting event from the same time. Opening the event showed a link to the error log.
Opening the error log showed that the error was related to a logical network issue on the cluster. This cluster has a converged network switch to which all virtual machines (VMs) connect. However, two additional logical networks are mapped to the switch to enable the migration of VMs which were connected to logical networks of a different name on a legacy cluster.
What I found is that some VMs were connected to the “Hyper-V External Access ” logical networks, rather than the ConvergedNetworkSwitch. Changing the network mapping of the affected VMs to ConvergedNetworkSwitch enabled me to run the Dynamic Optimization wizard.