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 ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
}
Looks like the arguments you passed, including the name of the CSV, are not accepted correctly.
How did you call the .ps1 file?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am new to powecli and need assistance if I am not executing it properly. I have followed the below steps.
I have saved .ps1 and input file (input.csv) under the path "C:\Scripts". I am opening the powercli and by connecting to the VC -> C:\Scripts. I executed the below command.
./My_storagevmotion.ps1 C:\Scripts\input.csv 4
The error seems to occur at line 1 in your .ps1 file.
It looks as if you didn't copy the lines before the line with Import-Csv
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi. As I couldn't able to find the issue, Is their any other scripts which I can use for my requirement.
Did you add the lines I mentioned earlier?
Attach the script you are currently using so I can have a closer look.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The error was on line 1.
That is not the script that caused the error.
At line:1 char:12
+ Import-csv $csvinput9 | foreach {
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference