{"id":55,"date":"2010-04-12T10:16:42","date_gmt":"2010-04-12T14:16:42","guid":{"rendered":"http:\/\/enterpriseadmins.org\/blog\/?p=55"},"modified":"2010-04-12T10:16:42","modified_gmt":"2010-04-12T14:16:42","slug":"storage-vmotion-with-thin-provisioning-in-powershell","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/storage-vmotion-with-thin-provisioning-in-powershell\/","title":{"rendered":"Storage vMotion with Thin-Provisioning in PowerShell"},"content":{"rendered":"<p>In an earlier post I mentioned a script written by a co-worker to determine all of the non-thinprovisioned virtual machines. \u00a0This script is a follow-up to that, which allows actually uses storage vMotion to resolve the problems. \u00a0It is important to note that this script does not provide ANY error checking &#8212; if you try to move virtual machines to a datastore that does not have enough capacity you&#8217;ll be in trouble. \u00a0However, I have used this script to re-arrange many virtual machines and it was successful (I always verified I had enough target\u00a0capacity\u00a0before starting the script).<\/p>\n<pre><code class=\"language-powershell\">$dsView = Get-Datastore -Name \"target-datastore\" | Get-View -Property Name\r\n\r\nGet-VM \"vm-num1\",\"vm-num2\" | % {\r\n$vmView = $_ | Get-View -Property Name\r\n$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec\r\n$spec.datastore =  $dsView.MoRef\r\n$spec.transform = \"sparse\"\r\n$vmView.RelocateVM($spec, $null)\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In an earlier post I mentioned a script written by a co-worker to determine all of the non-thinprovisioned virtual machines. \u00a0This script is a follow-up to that, which allows actually uses storage vMotion to resolve the problems. \u00a0It is important &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/storage-vmotion-with-thin-provisioning-in-powershell\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"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":[3,4],"tags":[],"class_list":["post-55","post","type-post","status-publish","format-standard","hentry","category-scripting","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/55","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":4,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/55\/revisions\/59"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}