problem with add-vmdisk

May 18, 2009 at 3:47 PM

Hi everyone,

I'm using ur great pool of tool and almost everyone works perfektly.

My problem is:

I create remote a VM on a Server 2008 Hyper-v.

I am using add-vmdrive and add-vmdisk.

add-vmdrive works perfekt and i get the message: "Added drive to 'dawidtest1'."

add-vmdisk dont work and it says: "Failed to add disk to 'dawidtest1', result code: 4096."

Even if i change add-vmdisk and write just bevor


sleep 10000

"if ($result -eq 0) {"Added disk to '$($vm.elementName)'."} else {"Failed to add disk to '$($vm.elementName)', result code: $result."}}"

nothing changes.

Please help.



May 19, 2009 at 2:17 PM

I tested it on the host and there it is running perfekt.

But a Server Core has no powershell yet.

Have anyone an idea how to get this great tool to work remote?

May 27, 2009 at 3:15 PM


I solved it.

My Problem was this line:

add-vmdisk $VMName 0 0 $ $VHD $Server

and  $VHD = \\hypervtest\d$\dawid1.vhd

so powershell searched for $\dawid1.vhd

i changed $VHD into "E:\vm\dawid1.vhd" and now it works

Oct 20, 2009 at 8:13 PM

I'm having a similar problem. I receive a 4096 error when adding a VHD through add-vmdisk

I'm using:

$vm = New-VM -name “MyPC”
Set-VMMemory -vm $vm -memory 512MB
Set-VMCPUCount -vm $vm -CPUCount 1
Add-VMDrive $vm 0 0
Add-VMDisk $VM 0 0 $ "C:\MyPC.vhd"

I get:

 Failed to add disk to 'MyPC', result code: 4096.

I've tried with different paths, existing and non-existing.


The add-vmdrive succeeds, but add-vmdisk fails and I'm left with an empty drive without file associated.

I've tried with clean machines, manually and with different ways of expressing the VHD path, and they all fail with the same error. I'm doing this on Windows Server 2008 R2, which could mean that there's some incompatibility. Has anyone tried adding disks with pshyperv on an R2 host?

Thank you.



Oct 31, 2009 at 5:28 PM

Add-VMDisk $VM 0 0 $ "C:\MyPC.vhd"

That $ shouldn't be there.

The VHD must exist , so do new-vhd  c:\myPC.vhd  (and set size, fixed or parent etc otherwise it will assume dynamic. )