tag:blogger.com,1999:blog-6230024559279811901.post5721806563120568398..comments2023-08-28T14:37:10.715-07:00Comments on I.T. Proctology: Modifying Hyper-V Generation2 VM boot device order with PowerShellBrianEhhttp://www.blogger.com/profile/09946552115562772058noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-6230024559279811901.post-27127746949401752882018-04-18T23:35:29.241-07:002018-04-18T23:35:29.241-07:00Even easier:
$vmname = "nameofyourvm"
$...Even easier:<br /><br />$vmname = "nameofyourvm"<br />$NetAdapter = Get-VMNetworkAdapter -VMName $vmname<br />Set-VMFirmware -VMName $vmname -FirstBootDevice $NetAdapter<br /><br />Yes, I could abbreviate it even further but this explains each step.<br />You could type out the name in line 1 or replace it with any number of methods to derive the name.<br />Then grab the network adapter, in this case assuming you run with just 1 adapter.<br />Lastly, set the network adapter as the first bootdevice.Anonymoushttps://www.blogger.com/profile/12725583769989449029noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-46890213771623690892015-12-03T12:34:25.365-08:002015-12-03T12:34:25.365-08:00We managed to get this working after some runs.
I...We managed to get this working after some runs.<br /><br />In our case our VMs have two VHDX files attached (OS/Data) so File,Net,Drive,Drive,Drive<br /><br />Depending on the initial order one needs to juggle the variables:<br /><br />$gen2r2 = Get-VMFirmware NameOfVM<br />$gen2r2.BootOrder<br />$genFile = $gen2r2.BootOrder[0]<br />$genNet = $gen2r2.BootOrder[1]<br />$genHD0 = $gen2r2.BootOrder[2]<br />$genDVD = $gen2r2.BootOrder[3]<br />$genHD1 = $gen2r2.BootOrder[4]<br />Set-VMFirmware -VMName NameOfVM -BootOrder $genHD0,$genDVD,$genHD1,$genNet,$genFile <br />Get-VMFirmware NameOfVM<br /><br />P.Philip Elder Cluster MVPhttps://www.blogger.com/profile/06082028960643490292noreply@blogger.comtag:blogger.com,1999:blog-6230024559279811901.post-90792960228126582492014-11-20T01:31:35.924-08:002014-11-20T01:31:35.924-08:00Thanks for the post it was very useful.
I ended u...Thanks for the post it was very useful.<br /><br />I ended up using a slightly simpler method to set the BootOrder.<br /><br />Get-VMDvdDrive<br />$MyDVD = Get-VMDvdDrive vm003<br />$MyHD = Get-VMHardDiskDrive vm003<br />$MyNIC = Get-VMNetworkAdapter vm003<br /><br />Set-VMFirmware vm003 -BootOrder $MyDVD, $MyHD, $MyNICMarchttps://www.blogger.com/profile/14947883373036395512noreply@blogger.com