Tag Archives: Hyper-V

Adding Virtual Machines to Hyper-V with PowerShell

After you’ve exported a VM from Hyper-V you may want to import a unique copy of it or several unique copies of it back into Hyper-V.

$i=1
Do
{
###################### Import Virtual Machine from Template ######################
$NewVMNumber=$i
$VMToImport='C:\Users\administrator.ISLEWORTHSYON\Desktop\isos\2016srv\Server 2016 Preview\Virtual Machines\E58E5FDD-03DF-4870-8725-5F63AD7D943D.xml'
$VMPath='D:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\S16'+$newVMNumber
$VMHDD='D:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\S16'+$newVMNumber
$NewVMName='Server 2016 Preview - S16'+$NewVMNumber

Import-VM -Path $VMToImport –Copy -GenerateNewId -VirtualMachinePath $VMPath -SnapshotFilePath $VMPath -SmartPagingFilePath $VMPath -VhdDestinationPath $VMHDD

Rename-VM 'Server 2016 Preview' -NewName $NewVMName

###################################### End #######################################
$i++
}
While ($i -le 2)

 

How to change the resolution on a virtual Ubuntu machine in Hyper-V

Modified from the original poster  at the following address on 2014-11-09:

http://blogs.msdn.com/b/virtual_pc_guy/archive/2014/09/19/changing-ubuntu-screen-resolution-in-a-hyper-v-vm.aspx

  1. Open Terminal
  2. Type: sudo nano /etc/default/grub
  3. Find the line starting with GRUB_CMDLINE_LINUX_DEFAULT, and add video=hyperv_fb:[the resolution you want].  The resolution I want is 1440x900.  So my line ends up looking like this: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1440x900"
  4. Write the changes and quit nano by pressing CTRL-O followed by enter to output the changed to the same file and then CTRL-X to exit.
  5. Run: sudo update-grub
  6. Reboot the virtual machine