{"id":6060,"date":"2018-08-23T10:42:29","date_gmt":"2018-08-23T10:42:29","guid":{"rendered":"https:\/\/www.isunshare.com\/blog\/?p=6060"},"modified":"2019-01-17T01:29:24","modified_gmt":"2019-01-17T01:29:24","slug":"how-to-create-a-virtual-machine-with-hyper-v-powershell-in-windows-10-100-working","status":"publish","type":"post","link":"https:\/\/www.isunshare.com\/blog\/how-to-create-a-virtual-machine-with-hyper-v-powershell-in-windows-10-100-working\/","title":{"rendered":"How to Create a Virtual Machine with Hyper-V\/ PowerShell in Windows 10 &#8211; 100% Working"},"content":{"rendered":"<p>Virtualization, which allows users to run multiple logical computers on one machine. Every logical computer can install an operating system at the same time. Furthermore, all of them run respectively without interference. VMware and VirtualBox are the most common and popular cross-platform virtualization products. However, fewer people know about the Windows built-in virtual machine. Since Windows 8, Microsoft provides two ways for us to create a virtual machine: Hyper-V or PowerShell. This document walks through<strong> how to create a virtual machine with Hyper-V or PowerShell in Windows 10<\/strong>.<\/p>\n<ul>\n<li><a href=\"#part1\">Part 1: Create a Virtual Machine with Hyper-V in Windows 10<\/a><\/li>\n<li><a href=\"#part2\">Part 2: Create a Virtual Machine with PowerShell in Windows 10<\/a><\/li>\n<\/ul>\n<h2 id=\"part1\">Part 1: Create a Virtual Machine with Hyper-V in Windows 10<\/h2>\n<p>Comparing to VMware and VirtualBox, Hyper-V spends less time to launch and power off through it doesn&#8217;t support using peripherals such as USB flash drive. What&#8217;s more, you cannot run VMware or VirtualBox while using Hyper-V.<\/p>\n<p><strong>NOTE:<\/strong> Hyper-V is available for all 64-bits versions in Windows 8 and later but not include Windows Home edition.<\/p>\n<h3>Step 1: Enable Virtualization in BIOS Windows 10<\/h3>\n<p>By default, the virtualization technology is disabled in BIOS settings. So, we have to enable the hardware virtualization in advance.<\/p>\n<p>1. Keeping pressing hotkey like <strong>Delete<\/strong> key while start or restart your computer.<\/p>\n<p>2. Under the <strong>Security<\/strong> tab, locate to <strong>System Security<\/strong> item and enable <strong>Virtualization Technology<\/strong>.<\/p>\n<p><a href=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-virtualization-technology.png\"><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"304\" class=\"alignnone size-full wp-image-6062\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-virtualization-technology.png\" alt=\"enable virtualization technology\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-virtualization-technology.png 500w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-virtualization-technology-300x182.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>3. Hit<strong> F10<\/strong> to save changes and exit.<\/p>\n<h3>Step 2: Enable Virtualization in Control Panel Windows 10<\/h3>\n<p>To create a virtual machine in Hyper-V Manager, you need to prepare an .iso file beforehand.<\/p>\n<p>1. Type <strong>Control Panel<\/strong> in the search bar and select it from the result;<\/p>\n<p>2. Click on <strong>Programs<\/strong>;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"263\" class=\"alignnone wp-image-7238 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs.png\" alt=\"control panel programs\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs.png 400w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs-300x197.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>3. Click <strong>Turn Windows features on or off<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"263\" class=\"alignnone wp-image-7239 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs-1.png\" alt=\"control panel programs\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs-1.png 400w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/control-panel-programs-1-300x197.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>4. Check the box of <strong>Hyper-V<\/strong> and click on <strong>OK<\/strong> button. Then you need to restart your PC to apply changes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"355\" class=\"alignnone wp-image-7240 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-hyper-v-windows-10.png\" alt=\"enable hyper v windows 10\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-hyper-v-windows-10.png 400w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/enable-hyper-v-windows-10-300x266.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<h3>Step 3: Create Virtual Machine with Hyper-V Manager<\/h3>\n<p>1. Search <strong>Hyper-V Manager<\/strong> and run it.<\/p>\n<p><a href=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-hyper-manager.png\"><img loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"516\" class=\"alignnone size-full wp-image-6066\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-hyper-manager.png\" alt=\"run hyper manager\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-hyper-manager.png 350w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-hyper-manager-203x300.png 203w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/a><\/p>\n<p>2. Click on <strong>Action<\/strong> &gt;<strong> New<\/strong> &gt; <strong>Virtual Machine<\/strong> and follow the wizard to create a Virtual Machine by Hyper-V in Windows 10.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"113\" class=\"alignnone size-full wp-image-7242\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/hyper-v-manager-action.png\" alt=\"hyper v manager action\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"378\" class=\"alignnone wp-image-7243 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/new-vm-wizard.png\" alt=\"new vm wizard\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/new-vm-wizard.png 500w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/new-vm-wizard-300x227.png 300w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<h2 id=\"part2\">Part 2: Create a Virtual Machine with PowerShell in Windows 10<\/h2>\n<p><strong>Step 1:<\/strong> You should enable virtualization in BIOS and control panel as Step 1-2 in Part 1 above.<\/p>\n<p><strong>Step 2:<\/strong> Open <strong>PowerShell\u00a0ISE<\/strong>, copy the following codes and paste into it. Save the file as My file.ps1 to the root directory of Drive D.<\/p>\n<div style=\"overflow-x: auto; width: 100%;\">\n<pre>$Server = \"Windows10\"               #Create VM name as Windows10\r\n$ServerRAM = 1GB                    #Set RAM size to 1 GB\r\n$ServerVHD = 60GB                   #Set VHD size to 80GB\r\n$VMLOC = \"D:\\HyperV\"                #Define where the virtual hard disk file is stored\r\n$Switch = \"TestSW\"                  #Define the name of the virtual switch\r\n$Ws2018ISO = \"E:\\iso\\Windows10.iso\" #Specify where to install the ISO file\r\n\r\n# Create folders and virtual throw switches for virtual machines\r\nMD $VMLOC -ErrorAction SilentlyContinue\r\n$TestSwitch = Get-VMSwitch -Name $Switch -ErrorAction SilentlyContinue; \r\nif ($TestSwitch.Count -EQ 0){New-VMSwitch -Name $Switch -SwitchType Private}\r\n\r\n# Create a new virtual machine\r\nNew-VM -Name $Server -Path $VMLOC -MemoryStartupBytes $ServerRAM -NewVHDPath \r\n$VMLOC\\$ServerVHD.vhdx -NewVHDSizeBytes $ServerVHD -SwitchName $Switch\r\n\r\n# Configuring a virtual machine\r\nSet-VMDvdDrive -VMName $Server -Path $Windows10ISO\r\n\r\n#Start the Virtual Machine\r\nStart-VM $Server\r\n<\/pre>\n<\/div>\n<p><strong>Step 3:<\/strong> Right-click on <strong>Start<\/strong> and choose <strong>Windows PowerShell (Admin)<\/strong> from the items.<\/p>\n<p><a href=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/windows-powershell-admin.png\"><img loading=\"lazy\" decoding=\"async\" width=\"268\" height=\"577\" class=\"alignnone size-full wp-image-6068\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/windows-powershell-admin.png\" alt=\"windows powershell admin\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/windows-powershell-admin.png 268w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/windows-powershell-admin-139x300.png 139w\" sizes=\"auto, (max-width: 268px) 100vw, 268px\" \/><\/a><\/p>\n<p><strong>Step 4:<\/strong> Run <strong>get-executionpolicy<\/strong> command to see the PowerShell execution policy. If it returns Restricted, you should run the <strong>set-executionpolicy remotesigned<\/strong> commend to get the highest authority to run the script then type <strong>Y<\/strong> and hit <strong>Enter<\/strong>. If it returns <strong>RemoteSigned<\/strong> to you, you can run the script directly.<\/p>\n<p><strong>Step 5:<\/strong> Due to my .ps1 file stored in Drive D, so type cd d: to switch the directory.<\/p>\n<p><a href=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/get-execution-policy.png\"><img loading=\"lazy\" decoding=\"async\" width=\"590\" height=\"159\" class=\"alignnone size-full wp-image-6069\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/get-execution-policy.png\" alt=\"get execution policy\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/get-execution-policy.png 590w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/get-execution-policy-300x81.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><strong>Step 6:<\/strong> Type <strong>&amp; &#8216;.\\My file.ps1&#8217;<\/strong> and hit <strong>Enter<\/strong>. When it finishes creating Virtual Machine, you can see it running on the Hyper-V Manager. Double-click on it to launch it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"96\" class=\"alignnone wp-image-7244 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-script-powershell.png\" alt=\"run script powershell\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-script-powershell.png 600w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-script-powershell-300x48.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><a href=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-windows-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"183\" class=\"alignnone size-full wp-image-6073\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-windows-10.png\" alt=\"run windows 10\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-windows-10.png 600w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/run-windows-10-300x92.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><strong>Note:<\/strong> If Windows blank screen at startup, you can click on Settings in the right panel. Locate to DVD Drive and select Image file and add your .iso file to the VM.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"193\" class=\"alignnone size-full wp-image-7245\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/click-settings.png\" alt=\"click settings\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/click-settings.png 600w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/click-settings-300x97.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/>\u00a0<img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"326\" class=\"alignnone wp-image-7246 size-full\" src=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/add-iso-file-to-dvd.png\" alt=\"add iso file to dvd\" srcset=\"https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/add-iso-file-to-dvd.png 600w, https:\/\/www.isunshare.com\/blog\/wp-content\/uploads\/2018\/08\/add-iso-file-to-dvd-300x163.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Virtualization, which allows users to run multiple logical computers on one machine. Every logical computer can install an&#8230;<\/p>\n","protected":false},"author":3,"featured_media":6091,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[214],"tags":[271,272],"class_list":["post-6060","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer","tag-how-to-create-a-virtual-machine-with-hyper-v-windows-10","tag-how-to-create-a-virtual-machine-with-powershell-windows-10"],"_links":{"self":[{"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/posts\/6060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/comments?post=6060"}],"version-history":[{"count":5,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/posts\/6060\/revisions"}],"predecessor-version":[{"id":7248,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/posts\/6060\/revisions\/7248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/media\/6091"}],"wp:attachment":[{"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/media?parent=6060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/categories?post=6060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.isunshare.com\/blog\/wp-json\/wp\/v2\/tags?post=6060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}