@@ -11,13 +11,13 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
1111 cfDevVHD = filepath .Join (d .Config .StateDir , "disk.vhdx" )
1212 )
1313
14- command := fmt .Sprintf ("New-VM -Name %s -Generation 2 -NoVHD" , name )
14+ command := fmt .Sprintf ("Hyper-V \\ New-VM -Name %s -Generation 2 -NoVHD" , name )
1515 _ , err := d .Powershell .Output (command )
1616 if err != nil {
1717 return "" , fmt .Errorf ("creating new vm: %s" , err )
1818 }
1919
20- command = fmt .Sprintf ("Set-VM -Name %s " +
20+ command = fmt .Sprintf ("Hyper-V \\ Set-VM -Name %s " +
2121 "-AutomaticStartAction Nothing " +
2222 "-AutomaticStopAction ShutDown " +
2323 "-CheckpointType Disabled " +
@@ -30,26 +30,26 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
3030 return "" , fmt .Errorf ("setting vm properites (memoryMB:%d, cpus:%d): %s" , memory , cpus , err )
3131 }
3232
33- command = fmt .Sprintf (`Add-VMDvdDrive -VMName %s -Path "%s"` , name , efiPath )
33+ command = fmt .Sprintf (`Hyper-V\ Add-VMDvdDrive -VMName %s -Path "%s"` , name , efiPath )
3434 _ , err = d .Powershell .Output (command )
3535 if err != nil {
3636 return "" , fmt .Errorf ("adding dvd drive %s: %s" , efiPath , err )
3737 }
3838
39- command = fmt .Sprintf ("Remove-VMNetworkAdapter -VMName %s" , name )
39+ command = fmt .Sprintf ("Hyper-V \\ Remove-VMNetworkAdapter -VMName %s" , name )
4040 _ , err = d .Powershell .Output (command )
4141 if err != nil {
4242 fmt .Printf ("failed to remove network adapter: %s" , err )
4343 }
4444
45- command = fmt .Sprintf ("Add-VMHardDiskDrive -VMName %s " +
45+ command = fmt .Sprintf ("Hyper-V \\ Add-VMHardDiskDrive -VMName %s " +
4646 `-Path "%s"` , name , cfDevVHD )
4747 _ , err = d .Powershell .Output (command )
4848 if err != nil {
4949 return "" , fmt .Errorf ("adding vhd %s : %s" , cfDevVHD , err )
5050 }
5151
52- command = fmt .Sprintf ("Set-VMFirmware " +
52+ command = fmt .Sprintf ("Hyper-V \\ Set-VMFirmware " +
5353 "-VMName %s " +
5454 "-EnableSecureBoot Off " +
5555 "-FirstBootDevice $cdrom" ,
@@ -59,7 +59,7 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
5959 return "" , fmt .Errorf ("setting firmware: %s" , err )
6060 }
6161
62- command = fmt .Sprintf ("Set-VMComPort " +
62+ command = fmt .Sprintf ("Hyper-V \\ Set-VMComPort " +
6363 "-VMName %s " +
6464 "-number 1 " +
6565 "-Path \\ \\ .\\ pipe\\ cfdev-com" ,
@@ -69,7 +69,7 @@ func (d *HyperV) CreateVM(name string, cpus int, memory int, efiPath string) (st
6969 return "" , fmt .Errorf ("setting com port: %s" , err )
7070 }
7171
72- output , err := d .Powershell .Output ("((Get-VM -Name cfdev).Id).Guid" )
72+ output , err := d .Powershell .Output ("((Hyper-V \\ Get-VM -Name cfdev).Id).Guid" )
7373 if err != nil {
7474 return "" , fmt .Errorf ("fetching VM Guid: %s" , err )
7575 }
@@ -85,7 +85,7 @@ func (d *HyperV) StartVM(vmName string) error {
8585 return fmt .Errorf ("hyperv vm with name %s does not exist" , vmName )
8686 }
8787
88- command := fmt .Sprintf ("Start-VM -Name %s" , vmName )
88+ command := fmt .Sprintf ("Hyper-V \\ Start-VM -Name %s" , vmName )
8989 if _ , err := d .Powershell .Output (command ); err != nil {
9090 return fmt .Errorf ("start-vm: %s" , err )
9191 }
@@ -100,7 +100,7 @@ func (d *HyperV) StopVM(vmName string) error {
100100 return nil
101101 }
102102
103- command := fmt .Sprintf ("Stop-VM -Name %s -Turnoff" , vmName )
103+ command := fmt .Sprintf ("Hyper-V \\ Stop-VM -Name %s -Turnoff" , vmName )
104104 if _ , err := d .Powershell .Output (command ); err != nil {
105105 return fmt .Errorf ("stopping vm: %s" , err )
106106 }
@@ -115,7 +115,7 @@ func (d *HyperV) DestroyVM(vmName string) error {
115115 return nil
116116 }
117117
118- command := fmt .Sprintf ("Remove-VM -Name %s -Force" , vmName )
118+ command := fmt .Sprintf ("Hyper-V \\ Remove-VM -Name %s -Force" , vmName )
119119 if _ , err := d .Powershell .Output (command ); err != nil {
120120 return fmt .Errorf ("removing vm: %s" , err )
121121 }
@@ -128,7 +128,7 @@ func (d *HyperV) IsVMRunning(vmName string) (bool, error) {
128128 return false , err
129129 }
130130
131- command := fmt .Sprintf ("Get-VM -Name %s | format-list -Property State" , vmName )
131+ command := fmt .Sprintf ("Hyper-V \\ Get-VM -Name %s | format-list -Property State" , vmName )
132132 output , err := d .Powershell .Output (command )
133133 if err != nil {
134134 return false , err
@@ -142,7 +142,7 @@ func (d *HyperV) IsVMRunning(vmName string) (bool, error) {
142142}
143143
144144func (d * HyperV ) exists (vmName string ) (bool , error ) {
145- command := fmt .Sprintf ("Get-VM -Name %s*" , vmName )
145+ command := fmt .Sprintf ("Hyper-V \\ Get-VM -Name %s*" , vmName )
146146 output , err := d .Powershell .Output (command )
147147 if err != nil {
148148 return false , fmt .Errorf ("getting vms: %s" , err )
0 commit comments