<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Storage vMotion with PowerCLI in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756132#M97543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The easiest Way is Move-VM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is a small script that I put together to help me with some VM Migrations I had recently.&lt;/P&gt;&lt;P&gt;I got a lot of help with this from others on this forum so thanks to those guys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script takes a list of VM Names from a text file and migrates them randomly to DataStores of your choosing.&lt;/P&gt;&lt;P&gt;i.e&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if your datastore names are DataStore1, DataStore2, Datastore3, LabStorage1, LabStorage2, TestStorage1&lt;/LI&gt;&lt;LI&gt;you want to move from TestStorage1 to one of the "DataStoreX" locations, in the script, set $storage equal to DataStore&lt;/LI&gt;&lt;LI&gt;The Script checks the amount of free space on all the "DataStoreX" locations and makes sure that it's greater than Provisioned Space + 20%&lt;/LI&gt;&lt;LI&gt;If the amount of free space is ok, VM's are randomly moved to the new locations&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$filelocation = Read-Host "Please enter the name of the target file, include the full path, E.g. c:\Temp\List.txt"&lt;/P&gt;&lt;P&gt;$VMs = get-vm (Get-Content $filelocation)&lt;/P&gt;&lt;P&gt;$storage = Get-Datastore | where {$_.name -match “Your_DataStore_Name_Goes_here"}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;foreach ($v in $VMs) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $random_Datastore_in_array = Get-Datastore -Name $storage.name | where {$_.freespacegb -GE ($v.provisionedspaceGB*1.20)} | Get-Random -Count 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Host "Storage vMotion of $v to $random_Datastore_in_array beginning"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move-VM -VM $v -Datastore $random_Datastore_in_array -Confirm:$false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-VM $v | Get-Datastore | &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @{N="Date";E={(Get-Date).ToString()}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="VM";E={($v).Name}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="LUN";E={$random_Datastore_in_array.Name}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="FreeSpace (GB)";E={[math]::Round($random_Datastore_in_array.FreeSpaceGB)}} | &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Export-Csv c:\Temp\Storage_migrations.csv -NoTypeInformation -Append&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;C:\Temp\Storage_migrations.csv&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Aug 2016 19:15:46 GMT</pubDate>
    <dc:creator>piercj2</dc:creator>
    <dc:date>2016-08-11T19:15:46Z</dc:date>
    <item>
      <title>Storage vMotion with PowerCLI</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756130#M97541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the easiest way to storage vmotion a VM with PowerCLI?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 14:01:36 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756130#M97541</guid>
      <dc:creator>TheVMinator</dc:creator>
      <dc:date>2016-08-11T14:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Storage vMotion with PowerCLI</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756131#M97542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;simply Move-VM cmdlet: &lt;A href="http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.powercli.cmdletref.doc/Move-VM.html" title="http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.powercli.cmdletref.doc/Move-VM.html"&gt;http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.powercli.cmdletref.doc/Move-VM.html&lt;/A&gt; and use datastore as destination&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 14:35:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756131#M97542</guid>
      <dc:creator>linotelera</dc:creator>
      <dc:date>2016-08-11T14:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Storage vMotion with PowerCLI</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756132#M97543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The easiest Way is Move-VM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is a small script that I put together to help me with some VM Migrations I had recently.&lt;/P&gt;&lt;P&gt;I got a lot of help with this from others on this forum so thanks to those guys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script takes a list of VM Names from a text file and migrates them randomly to DataStores of your choosing.&lt;/P&gt;&lt;P&gt;i.e&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if your datastore names are DataStore1, DataStore2, Datastore3, LabStorage1, LabStorage2, TestStorage1&lt;/LI&gt;&lt;LI&gt;you want to move from TestStorage1 to one of the "DataStoreX" locations, in the script, set $storage equal to DataStore&lt;/LI&gt;&lt;LI&gt;The Script checks the amount of free space on all the "DataStoreX" locations and makes sure that it's greater than Provisioned Space + 20%&lt;/LI&gt;&lt;LI&gt;If the amount of free space is ok, VM's are randomly moved to the new locations&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$filelocation = Read-Host "Please enter the name of the target file, include the full path, E.g. c:\Temp\List.txt"&lt;/P&gt;&lt;P&gt;$VMs = get-vm (Get-Content $filelocation)&lt;/P&gt;&lt;P&gt;$storage = Get-Datastore | where {$_.name -match “Your_DataStore_Name_Goes_here"}&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;foreach ($v in $VMs) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $random_Datastore_in_array = Get-Datastore -Name $storage.name | where {$_.freespacegb -GE ($v.provisionedspaceGB*1.20)} | Get-Random -Count 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Host "Storage vMotion of $v to $random_Datastore_in_array beginning"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Move-VM -VM $v -Datastore $random_Datastore_in_array -Confirm:$false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get-VM $v | Get-Datastore | &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select @{N="Date";E={(Get-Date).ToString()}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="VM";E={($v).Name}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="LUN";E={$random_Datastore_in_array.Name}}, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @{N="FreeSpace (GB)";E={[math]::Round($random_Datastore_in_array.FreeSpaceGB)}} | &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Export-Csv c:\Temp\Storage_migrations.csv -NoTypeInformation -Append&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;C:\Temp\Storage_migrations.csv&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 19:15:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756132#M97543</guid>
      <dc:creator>piercj2</dc:creator>
      <dc:date>2016-08-11T19:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Storage vMotion with PowerCLI</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756133#M97544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK great - thanks!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2016 22:05:23 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-vMotion-with-PowerCLI/m-p/2756133#M97544</guid>
      <dc:creator>TheVMinator</dc:creator>
      <dc:date>2016-08-11T22:05:23Z</dc:date>
    </item>
  </channel>
</rss>

