{"id":799,"date":"2023-03-26T13:07:03","date_gmt":"2023-03-26T12:07:03","guid":{"rendered":"http:\/\/192.168.8.14\/?p=799"},"modified":"2023-03-26T13:13:11","modified_gmt":"2023-03-26T12:13:11","slug":"a-quick-shutdown-start-vm-script","status":"publish","type":"post","link":"https:\/\/www.jasonstreet.com\/?p=799","title":{"rendered":"A quick shutdown \/ start VM script"},"content":{"rendered":"\n<p>Today I got a text from a co-worker who needed to shutdown a load of VMs before doing some maintenance, then power them all on after.<\/p>\n\n\n\n<p>So here is a quick script I put together to do that<\/p>\n\n\n\n<p>First put you list of VMs in a CSV file, formatted like this<\/p>\n\n\n\n<p>VMname<br>VM1<br>VM2<br>VM3<\/p>\n\n\n\n<p>then edit this script and set the path to your CSV and the FQDN of your vCenter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$VMCSVPath = \"C:\\temp\\VMs.csv\"\n$vCenter = \"FQDN\" # FQDN or Ip of the vCenter\n\n$VMlist = import-csv $VMCSVPath\nconnect-viserver $vCenter\n\nforeach ($VMname in $VMlist)\r\n{\r\n    $VM = get-vm $VMname.VMname\r\n    # shut down a VM using the vmware tools\r\n    #if ($VM) {$VM | shutdown-guest -confirm:$false}\r\n\r\n    # power off a VM \r\n    #if ($VM) {$VM | stop-vm -confirm:$false}\r\n\r\n    # power on a VM \r\n    #if ($VM) {$VM | start-vm -confirm:$false}\r\n}\n<\/code><\/pre>\n\n\n\n<p>Then remove the commant from the line you want to run (shutdown, power off or power on)<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I got a text from a co-worker who needed to shutdown a load of VMs before doing some maintenance, then power them all on after. So here is a quick script I put together to do that First put you list of VMs in a CSV file, formatted like this VMnameVM1VM2VM3 then edit this&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-799","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=799"}],"version-history":[{"count":4,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/799\/revisions\/803"}],"wp:attachment":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}