{"id":227,"date":"2017-05-03T16:58:32","date_gmt":"2017-05-03T16:58:32","guid":{"rendered":"https:\/\/www.indycloudcover.com\/?p=227"},"modified":"2018-04-26T09:37:52","modified_gmt":"2018-04-26T14:37:52","slug":"removing-a-datastore-with-powerclipowershell","status":"publish","type":"post","link":"https:\/\/www.indycloudcover.com\/?p=227","title":{"rendered":"Removing a Datastore with PowerCLI\/Powershell"},"content":{"rendered":"<p>Another issue that comes along with power outages?  Hosts coming back up before their storage&#8230;  With fiber channel, you can typically reconnect it with a refresh\/rescan, but with NFS, they tend to become disconnected.  <\/p>\n<p>The fix is to remove and re-add the Datastore (see <a href=\"https:\/\/kb.vmware.com\/selfservice\/microsites\/search.do?language=en_US&#038;cmd=displayKC&#038;externalId=1005057\">kb 1005057<\/a>)<\/p>\n<p>With no way to handle them en masse in the gui and no desire to have to repeat this process in the future,  I used Powershell!<\/p>\n<p>Here is the raw script, I will add comments in the near future for those interested.  <\/p>\n<p>I chose to run this per cluster<\/p>\n<pre class=\"toolbar:1 lang:ps decode:true \" >Add-PSSnapin Vmware.VimAutomation.Core -ea SilentlyContinue\r\nImport-Module Vmware.VimAutomation.Core -ea SilentlyContinue\r\nconnect-viserver \"vCenter-Name\"\r\n$hosts = get-vmhost -location \"Cluster-001\"\r\nforeach ($VMHost in $hosts) {\r\nWrite-Host $VMHost.name\r\nRemove-Datastore -VMHost $VMHost -Datastore \"ISO\" -Confirm:$false\r\n}\r\n\r\nDisconnect-VIServer * -Confirm:$false<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Another issue that comes along with power outages? Hosts coming back up before their storage&#8230; With fiber channel, you can typically reconnect it with a refresh\/rescan, but with NFS, they tend to become disconnected. The fix is to remove and re-add the Datastore (see kb 1005057) With no way to handle them en masse in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/posts\/227"}],"collection":[{"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=227"}],"version-history":[{"count":4,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":278,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions\/278"}],"wp:attachment":[{"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.indycloudcover.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}