Get-VHDDefaultPath returning nothing?

Dec 8, 2010 at 8:22 PM

I've recently discovered this library, and am working on improving a backup of VHD script.  One of the things I'd like to do is use the assorted Get-VHD... commands to get the name and path of the VHD files for VMs, and pass that to a robocopy command.

The problem I am having, is that Get-VHDDefaultPath when run, does not return anything.  It does not give an error, it simply returns nothing.  I did, once the Hyper-V role was installed, change the default path for VHDs in the Hyper-V Manager.  Oddly, on a second Hyper-V server, it does work.  It also will work if I run it from a remote computer, with the -Server option, but even if I specify this option when running it locally, it will return nothing.

If I run Get-VHD -path {path to VHDs} it does return a list of my VHDs.  While I could "hard code" the path in the script, I'd like to be able to simply copy this script to any other Hyper-V servers I need it on, and require minimal editing once it is there.

Specs of the non-working server:  Windows Server 2008 Datacenter R2

Specs of the working server:  Microsoft Hyper-V Server R2

Is it possible there is an issue with get-wmi?  I've tried running the command used,

Get-WmiObject -computerName Hyperv02 -Namespace "root\virtualization" -Class "MsVM_VirtualSystemManagementServiceSettingData"
which also returns nothing.

If needed, I can provide further details.

Thank you, and thank you for this very helpful set of tools!

Jason A.

Coordinator
Feb 4, 2011 at 4:56 PM

Sorry this reply has taken a while - this is very strange . The command you are entering is correct and should send back 10 or a dozen bits of data about the server.

What you can also do is start wbemTest click connect, and enter  root\virtualization then click connect again. Then click enum_Instances and enter MsVM_VirtualSystemManagementServiceSettingData. You should get one object back - which you can double click to expand.

I'm prepared to bet that on the working system this will give you the object and the broken one won't - WHY and what to do about it I don't know (at the moment).

I had another issue recently with datacenter not returning the expect WMI objects and I have a suspicion the cause might be the same.