looking for a script which helps to perform svmotion. performing 4 VM storage vmotion at a given time.

This post was originally published on this site

I am looking for a script which helps to perform svmotion (performing 4 VM storage vmotion at a given time). I found the below script fulfills my requirement. but for some reason I am getting the error as below. Any assistance is greatly appreciated.

 

Error Received:

Import-Csv : Cannot validate argument on parameter ‘Path’. The argument is null or empty. Provide an argument that is

not null or empty, and then try the command again.

At line:1 char:12

+ Import-csv $csvinput9 | foreach {

+            ~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Import-Csv], ParameterBindingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportCsvCommand

 

 

Script used : (https://ranchh.wordpress.com/2018/02/16/powershell-script-vmware-storage-vmotion/)

 

$csvinput = $args[0]

$maxsession = $args[1]

$runsession = 0

 

echo “—————Summary—————-“

echo “This script is to perform the Virtual Storage vMotion with give max sessions”

echo “————————————–“

import-csv $csvinput | foreach {

 

echo “————————————————“

echo “Checking the running vMotion now…. Pls wait….”

echo “————————————————“

 

Do {

 

$runsession = (get-task | where {$_.name -like “RelocateVM_Task” -and $_.State -eq “Running” }).count

 

if ($runsession -ge $maxsession) {

  echo “The current running vMotion sessions is $runsession.No new vMotion will be started.Next check will be performed in 1 minute.”

  Start-Sleep -s 60

  get-task | where {$_.State -eq “running”}

  }

 

else {

  echo “The current running vMotion sessions is $runsession, a new storage vMotion will be started soon.”

  Start-Sleep -s 5

  }

 

} While ( $runsession -ge $maxsession)

 

 

 

 

echo “>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>”

echo “The Storage vMotion for will start for below VM …”

echo $_.vmname

echo $_.targetds

Get-VM $_.vmname | Move-VM -Datastore $_.targetds -RunAsync -Confirm:$false

echo “>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>”

 

}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.