{"id":367,"date":"2021-04-16T18:51:05","date_gmt":"2021-04-16T18:51:05","guid":{"rendered":"https:\/\/thecloudwiki.com\/?p=367"},"modified":"2021-06-20T17:58:56","modified_gmt":"2021-06-20T17:58:56","slug":"simple-scripts-01-vm-exists-reboot-delete","status":"publish","type":"post","link":"https:\/\/thecloudwiki.com\/?p=367","title":{"rendered":"PowerCLI &#8211; Simple scripts &#8211; 01 (VM Exists, Reboot, Stop &#038; Delete)"},"content":{"rendered":"\n<p class=\"has-extra-small-font-size wp-block-paragraph\">At sometimes the simple scripts are useful to accomplish a complex task. rather than spending hours manually going through UI search and act, we can create simple PowerShell\/powercli scripts.<\/p>\n\n\n\n<p class=\"has-extra-small-font-size wp-block-paragraph\">In this article we will discuss few of them.<\/p>\n\n\n\n<p class=\"has-extra-small-font-size wp-block-paragraph\">Check whether the VM exists in a specific cluster (remove cluster if you would like to target in a vCenter)<\/p>\n\n\n\n<div class=\"wp-block-coblocks-gist\"><script src=\"https:\/\/gist.github.com\/sandeep-sr\/68e2a1dc0b04d92e8416afc30692191c.js\"><\/script><noscript><a href=\"https:\/\/gist.github.com\/sandeep-sr\/68e2a1dc0b04d92e8416afc30692191c\">View this gist on GitHub<\/a><\/noscript><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"> <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-extra-small-font-size wp-block-paragraph\">Reboot multiple VM&#8217;s in a cluster (remove cluster if you would like to target in a vCenter)<\/p>\n\n\n\n<div class=\"wp-block-coblocks-gist\"><script src=\"https:\/\/gist.github.com\/sandeep-sr\/f309f259b656c0421ec9c026a125d609.js\"><\/script><noscript><a href=\"https:\/\/gist.github.com\/sandeep-sr\/f309f259b656c0421ec9c026a125d609\">View this gist on GitHub<\/a><\/noscript><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-extra-small-font-size wp-block-paragraph\">Stop or power-off multiple VM&#8217;s (assuming the same name of VM isn&#8217;t exist in other clusters of vCenter)<\/p>\n\n\n\n<div class=\"wp-block-coblocks-gist\"><script src=\"https:\/\/gist.github.com\/sandeep-sr\/08440740b44e92ffc05c8cba09ab08a6.js\"><\/script><noscript><a href=\"https:\/\/gist.github.com\/sandeep-sr\/08440740b44e92ffc05c8cba09ab08a6\">View this gist on GitHub<\/a><\/noscript><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-extra-small-font-size wp-block-paragraph\">Delete multiple VM&#8217;s (please be careful and check multiple times before executing deletion since it&#8217;s a permanent data loss)<\/p>\n\n\n\n<div class=\"wp-block-coblocks-gist\"><script src=\"https:\/\/gist.github.com\/sandeep-sr\/43609439c5991ac3324cc3f71aa826fe.js\"><\/script><noscript><a href=\"https:\/\/gist.github.com\/sandeep-sr\/43609439c5991ac3324cc3f71aa826fe\">View this gist on GitHub<\/a><\/noscript><\/div>\n","protected":false},"excerpt":{"rendered":"<p>At sometimes the simple scripts are useful to accomplish a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1276,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[23],"tags":[5],"class_list":["post-367","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell"],"uagb_featured_image_src":{"full":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-e1624184854589.png",400,247,false],"thumbnail":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-150x150.png",150,150,true],"medium":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-300x185.png",300,185,true],"medium_large":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-768x474.png",768,474,true],"large":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-1024x632.png",1024,632,true],"1536x1536":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-e1624184854589.png",400,247,false],"2048x2048":["https:\/\/thecloudwiki.com\/wp-content\/uploads\/2021\/04\/powercli-simplescripts-feature-image-e1624184854589.png",400,247,false]},"uagb_author_info":{"display_name":"Sandeep","author_link":"https:\/\/thecloudwiki.com\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":"At sometimes the simple scripts are useful to accomplish a [&hellip;]","_links":{"self":[{"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=367"}],"version-history":[{"count":7,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/367\/revisions"}],"predecessor-version":[{"id":1278,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/posts\/367\/revisions\/1278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=\/wp\/v2\/media\/1276"}],"wp:attachment":[{"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecloudwiki.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}