-->

PowerCLI Script – VMware Storage vMotion

This article describes how to perform storage VMotion.

What is storage VMotion ?

VMware Storage VMotion allows virtual machines’ disks to be relocated to different data store locations completely transparently while the virtual machine is running, with zero downtime

Sometimes jobs are stuck in queue state, there is two options for migration
One is restart the vpxd services and then perform the storage migration from vCenters level.
Second option is perform command line.

Incase, if you want run storage migration through command line

Login Power CLI.
Below script save as PS1 format and run it.
it will ask vCenter and datastore details. We can monitor storage migration in tasks/events tab in vCenter.

The script as below:
================================================================================================================================================================

$vcname=Read-Host "Enter vcenter name"
connect-viserver -server $vcname
$myvm=read-host "enter vm name"
$ds= read-host "enter DS name"
Get-VM “$myvM“ |Move-VM -datastore (Get-datastore “$ds“) -RunAsync

do {
$GoAhead = Read-Host "Are you want to another Storage vmotion? type Y for yes and N for no "

if ($GoAhead -eq "yes" -or $GoAhead -eq "y" -or $GoAhead -eq "Y"){

$myvm=read-host "enter vm name"
$ds= read-host "enter DS name"
Get-VM “$myvM“ |Move-VM -datastore (Get-datastore “$ds“) -RunAsync
 
}
}
until ( $GoAhead -eq "no" -or  $GoAhead -eq "n" -or  $GoAhead -eq "N")

================================================================================================================================================================


PowerCLI Script – VMware Storage vMotion PowerCLI Script – VMware Storage vMotion Reviewed by Virtulization on February 11, 2017 Rating: 5

No comments:

Home - PageNavi (show/hide)

hide
Powered by Blogger.