What is wrong with the last line "$scheduledTaskManager.CreateScheduledTask($vmView.MoRef, $task) " ?
The ScheduledTaskManager is in the Service Instance.
$si = get-view ServiceInstance
$scheduledTaskManager = Get-View $si.Content.ScheduledTaskManager
We need to identify the VM and the host where it will be powered on.
#$vmView = Get-VM PowerOnTest | Get-View
#$esxView = Get-VMHost esx35-01.vitoolkit.local | Get-View
foreach ($f in (import-csv `
Now we construct the task argument.
$arg = New-Object VMware.Vim.MethodActionArgument
#$arg.Value = $esxview.MoRef
$action = New-Object VMware.Vim.MethodAction
$action.Argument = $arg
$action.Name = "PowerOnVM_Task"
$scheduler = new-object VMware.Vim.OnceTaskScheduler
$scheduler.runat = (get-date).addminutes(5)
$task = New-Object VMware.Vim.ScheduledTaskSpec
$task.Action = $action
$task.Description = "Start a VM with a scheduled task."
$task.Enabled = $true
$task.Name = "Power On Virtual Machine"
$task.Scheduler = $scheduler
should I start a new thread to give more Points. I already migrated with our scripts 321 VM. That is about 17 TB. Now the next 274 VM's (18 TB) will be migrated.
While ($DestView.Info.FreeSpace -> This checks if enough space is on the datastore
$MaxConcurrent = 2 and RunAsync | Wait-task -> this checks when the task is finished and starts the next motion.
Hello Luc ,
following line can be changed .
$spec.Description = "Migrate " + $_.VMname + " to " + $tgtDatastore
$spec.Description = "Migrate " + $_.VMname + " to " + $_.Datastore
I'd like to build on the scrip to add the ability,