New-VM Error: You cannot call a method on a null-valued expression

Jan 30, 2009 at 4:17 AM
Edited Jan 30, 2009 at 4:20 AM
I have a clean Hyper-V system, fully patched, with no VMs, and have using V1.0 of the Hyper-V library.

The sequence of events:

Load PowerShell

PS C:\Scripts> . ./HyperV.PS1

VM Functions loaded

Name
----
Add-VMDISK
...

PS C:\Scripts> $DC = New-VM "ZZDC2"
You cannot call a method on a null-valued expression.
At C:\Windows\setup\Scripts\hyperv.ps1:770 char:39
+   $arguments = @($vmGsd.psbase.GetText( <<<< [System.Management.TextFormat]::WmiDtd20),$null,$null,$null,$null)

0
Created VM 'ZZDC2'

At this point the VM is created but the name is "New Virtual Machine". $DC appears to be null. I can then retrieve the VM using Get-VM and work on it normally - including renaming it with Set-VM.

Coordinator
Jan 31, 2009 at 12:40 AM
This affected only PowerShell V1 , and was missed as I did the final tests on V2. 

The new 1.00a release has the fix in.