Add-VMPassThrough isn't working


I am brand new to powershell but I'm hoping to learn it so I can better manage my VMs.
I've got HyperV running on "Server 2008 R2 Datacenter" with your brilliant library added.
I've set up 8 vms all using powershell so I'm very pleased with myself :)
The problem I have run into is when I try to add Pass Through Disks.
I have set up 10 Offline disks and I can assign them correctly when using the HyperV MMC, however, when I try to use Powershell I get no joy
In my example I have a server named SVPN2-VM03
I want to add it to the 3rd available target to be its only hard drive
I entered the command below (the vm name is stored in the variable)
           Add-VMPassThrough $vm 0 0 (Select-VMPhysicalDisk)

I was then prompted to choose an ID but after that it returns an error (see below)

Add-VMPassThrough : A positional parameter cannot be found that accepts argument 'SVPN2-VM3'.
At line:1 char:18
  • Add-VMPassThrough <<<< $vm 0 0 (Select-VMPhysicalDisk)
    • CategoryInfo : InvalidArgument: (:) [Add-VMPassThrough], ParameterBindingException

+ FullyQualifiedErrorId : PositionalParameterNotFound,Add-VMPassThrough

It seems like something is missing? Have I made a mistake or is it a bug?
I've attached a picture of the error and what I am able to do through the GUI of the HyperV MMC

file attachments

Closed Mar 10, 2011 at 6:58 PM by jamesone
No fix needed


jamesone wrote Feb 4, 2011 at 11:11 AM

Under investigation

jamesone wrote Feb 4, 2011 at 4:22 PM

This is an issue that occurs in several places where I allow you to either pass an object which represents a disk / controller, or identify the contoller / disk by specifying the VM, controller, and Lun.
I think it is Powershell being obtuse, but you have to name the parameters in these case.
Add-VMPassThrough -vm $vm -co 0 -lun 0 -ph (Select-VMPhysicalDisk)
Add-VMPassThrough $vm 0 0 (Select-VMPhysicalDisk)
and powershell won't be able to work out which parameter is which.

wrote Mar 10, 2011 at 6:58 PM

wrote Feb 22, 2013 at 12:24 AM

wrote May 16, 2013 at 11:39 AM

mtn_lion wrote May 6, 2014 at 5:38 AM

Can this powershell command work for USB disks (offline in host OS)? How to specify controller id?
Yes, still trying to get along in 2008r2...