{"id":2714,"date":"2013-10-18T00:01:00","date_gmt":"2013-10-18T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/10\/18\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-5\/"},"modified":"2013-10-18T00:01:00","modified_gmt":"2013-10-18T00:01:00","slug":"recovering-virtual-machines-in-hyper-v-server-2012-r2-part-5","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-5\/","title":{"rendered":"Recovering Virtual Machines in Hyper-V Server 2012 R2: Part 5"},"content":{"rendered":"<p><strong>Summary<\/strong>: Adjust virtual machine settings by using only Windows PowerShell.\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\">&nbsp;Hey, Scripting Guy! I need to adjust the settings for some virtual machines on a Hyper-V box. How can I do that without using the GUI?\n&mdash;TM\n<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\">&nbsp;Hello TM,\nHonorary Scripting Guy, Sean Kearney here&mdash;filling in for our good friend Ed.<\/p>\n<p style=\"padding-left: 30px\"><strong>Note<\/strong>&nbsp;&nbsp;This is the fifth post in a series. To review, see:<\/p>\n<ul>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/14\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-1.aspx\" target=\"_blank\">Recovering Virtual Machines in Hyper-V Server 2012 R2: Part 1<\/a><\/li>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/15\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-2.aspx\" target=\"_blank\">Recovering Virtual Machines in Hyper-V Server 2012 R2: Part 2<\/a><\/li>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/16\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-3.aspx\" target=\"_blank\">Recovering Virtual Machines in Hyper-V Server 2012 R2: Part 3<\/a><\/li>\n<li><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/17\/recovering-virtual-machines-in-hyper-v-server-2012-r2-part-4.aspx\" target=\"_blank\">Recovering Virtual Machines in Hyper-V Server 2012 R2: Part 4<\/a><\/li>\n<\/ul>\n<p>There is probably a strong misconception of &ldquo;If I don&rsquo;t have the GUI, I can&rsquo;t manage Hyper-V.&rdquo; But this really isn&rsquo;t the case when you have Windows PowerShell.\nWhen we have a series of virtual machines imported, we can use Windows PowerShell cmdlets to manage these virtual machines.\nFor example, we might want to ensure that our virtual domain controller always starts automatically:<\/p>\n<p style=\"padding-left: 30px\">GET-VM &lsquo;CONTOSO-DC&rsquo; | SET-VM &ndash;automaticstartaction Start\nOr maybe I want to power up all of the virtual machines:<\/p>\n<p style=\"padding-left: 30px\">GET-VM | START-VM\n(By the way, with a lot of virtual machines, this could get a little slow.)\nIf we need to find out which of those virtual machines are running:<\/p>\n<p style=\"padding-left: 30px\">GET-VM | Where { $_.State &ndash;eq &lsquo;Running&rsquo; }\nWe also can adjust the memory configuration of these virtual machines. For example if I want to adjust the memory of a virtual machine:<\/p>\n<p style=\"padding-left: 30px\">SET-VM &lsquo;CONTOSOVM1&rsquo; &ndash;memorystartupbytes 512MB\nOr perhaps we made some mistakes and we need to get rid of a virtual machine:<\/p>\n<p style=\"padding-left: 30px\">GET-VM &lsquo;CONTOSOVM1&rsquo; | REMOVE-VM\nBut perhaps I need to make a more deliberate removal? I always used to hate using the GUI to delete a virtual machine that I wanted to permanently remove because I would have to clean up afterwards.\nWe can do this easily with Windows PowerShell:<\/p>\n<p style=\"padding-left: 30px\">$DiskList=GET-VM &lsquo;CONTOSOVM1&rsquo; | GET-VMHardDiskDrive | Select-object Path<\/p>\n<p style=\"padding-left: 30px\">STOP-VM &lsquo;CONTOSOVM1&rsquo;<\/p>\n<p style=\"padding-left: 30px\">$DiskList | Remove-item $_ -force<\/p>\n<p style=\"padding-left: 30px\">REMOVE-VM &lsquo;CONTOSOVM1&rsquo;\nIn fact, we presently have over 178 Hyper-V cmdlets to manage the environment by using only Windows PowerShell.\nSo there you have it. &nbsp;If you are running the free version of Hyper-V Server&nbsp;2012&nbsp;R2, there is very little stopping you from recovering virtual machines in it&mdash;even it if you don&rsquo;t have the GUI to work with.\nAnd remember, you can still join this virtual machine to a domain, set it up in a high availability Hyper-V cluster, and implement VHD replication!\nPop into this weekend as more Windows PowerShell excitement continues!\nI invite you to follow the Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to <a href=\"http:\/\/blogs.technet.commailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.\n<strong>Sean Kearney, <\/strong>Honorary Scripting Guy and Windows PowerShell MVP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Adjust virtual machine settings by using only Windows PowerShell. &nbsp;Hey, Scripting Guy! I need to adjust the settings for some virtual machines on a Hyper-V box. How can I do that without using the GUI? &mdash;TM &nbsp;Hello TM, Honorary Scripting Guy, Sean Kearney here&mdash;filling in for our good friend Ed. Note&nbsp;&nbsp;This is the fifth [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,271,3,154,45],"class_list":["post-2714","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-hyper-v","tag-scripting-guy","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Adjust virtual machine settings by using only Windows PowerShell. &nbsp;Hey, Scripting Guy! I need to adjust the settings for some virtual machines on a Hyper-V box. How can I do that without using the GUI? &mdash;TM &nbsp;Hello TM, Honorary Scripting Guy, Sean Kearney here&mdash;filling in for our good friend Ed. Note&nbsp;&nbsp;This is the fifth [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2714","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2714"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2714\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}