{"id":2922,"date":"2019-09-06T20:14:51","date_gmt":"2019-09-06T20:14:51","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=2922"},"modified":"2019-09-06T20:14:51","modified_gmt":"2019-09-06T20:14:51","slug":"create-and-configure-virtual-machine-with-powershell","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=2922","title":{"rendered":"Create and Configure Virtual Machine with PowerShell"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Create New Virtual Machine<\/h3>\n\n\n\n<p>Let&#8217;s go to create the new virtual machine. Type<\/p>\n\n\n\n<p><em>new-vm -vmname test -memorystartupbytes 1GB<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/new-vm-powershell.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Create Virtual Hard Drive<\/h3>\n\n\n\n<p><em>new-vhd&nbsp;-path &#8220;C:\\users\\Public\\Documents\\Hyper-v\\Virtual Hard Disks\\test.vhdx&#8221; -sizebytes 20GB -fixed<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/create-vm-hd-powershell.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Use the -fixed to determine that your Virtual Hard Drive will be fixed. Because by default use Dynamic Virtual Hard Disk Type.<\/p>\n\n\n\n<p>After create the Virtual Hard Disk you will see the results to verify the type of your VHD.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/get-vhd-details.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Attach Virtual Hard Drive in the Virtual Machine<\/h3>\n\n\n\n<p><em>add-vmharddiskdrive -vmname test -path&nbsp;&#8220;C:\\users\\Public\\Documents\\Hyper-v\\Virtual Hard Disks\\test.vhdx&#8221; -controllertype IDE -controllernumber 0 -location 1<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/set-vm-hd-powershell.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Connect Network Adapter in Virtual Machine<\/h3>\n\n\n\n<p>Find the name of the Network Adapter for the new Virtual Machine<\/p>\n\n\n\n<p><em>get-vmnetworkadapter -vmname test<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/get-vmnetworkadapter.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Identify the name of the Virtual Switch from HYPER-V Host &nbsp;that will be connect.<\/p>\n\n\n\n<p><em>get-vmswitch<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/get-vmswitch.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Connect the network adapter of the new Virtual Machine with the Virtual Switch. So now your Virtual Machine is connected in the network that use the Virtual Switch.<\/p>\n\n\n\n<p>connect-vmnetworkadapter -vmname test -vmnetworkadaptername &#8220;network adapter&#8221; -switchname &nbsp;&#8220;new virtual switch&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/connect-vmnetworkadapter.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Verify the connection with&nbsp;<\/p>\n\n\n\n<p><em>get-vmnetworkadapter -vmname test<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/get-vmnetworkadapter-afterconnect.png\" alt=\"\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Specify ISO to boot the VM<\/h3>\n\n\n\n<p><em>set-vmdvddrive -vmname test -controlnumber 1 -path &#8220;C:\\users\\user\\Documents\\ISO\\Windows8.1 Professional_w_SP1_x64.ISO&#8221;<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/setiso-vm.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>Start the VM to install the Windows<\/p>\n\n\n\n<p><em>start-vm -vmname test<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"http:\/\/www.askme4tech.com\/sites\/default\/files\/boot-vm-win8iso.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>This article explains only\u00a0basic commands on how can create a new Virtual Machine and configure it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create New Virtual Machine Let&#8217;s go to create the new virtual machine. Type new-vm -vmname test -memorystartupbytes 1GB Create Virtual Hard Drive new-vhd&nbsp;-path &#8220;C:\\users\\Public\\Documents\\Hyper-v\\Virtual Hard Disks\\test.vhdx&#8221; -sizebytes 20GB -fixed Use the -fixed to determine that your Virtual Hard Drive will be fixed. Because by default use Dynamic Virtual Hard Disk Type. After create the Virtual [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51,59,53],"tags":[],"class_list":["post-2922","post","type-post","status-publish","format-standard","hentry","category-server-virtualization-hyper-v-2","category-powershell","category-virtualization-virtual"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2922"}],"version-history":[{"count":1,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2922\/revisions"}],"predecessor-version":[{"id":2923,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2922\/revisions\/2923"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}