Hi All!
I try to make a script when it detects that in vcenter Server there is no task running, call another scrip and run it, and if not meanwhile wait for the tasks to finish running and so once the tasks are running, run the other script..
any idea?
thanks!
This will wait until the running tasks on your vCenter are completed, and then start a script.
while(Get-Task -Status Running -Server $global:DefaultVIServer){
sleep 10
}
.\other-script.ps1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What exactly do you mean with "there is no task running"?
I hope you are not running PowerCLI scripts on your vCenter?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
for example to no task of machine migration or similar in execution in the vCenter
No, no, im not running PowerCLI scripts on my vCenter
thanks
Do {Wait-Event -Timeout 10; Write-Host State: Running} While ((Get-Task).State -eq 'Running'); Script.ps1
every ten seconds we check whether there are any running tasks with simultaneous printing of "State: Running". As the absence of tasks is detected, the script is launched.
This will wait until the running tasks on your vCenter are completed, and then start a script.
while(Get-Task -Status Running -Server $global:DefaultVIServer){
sleep 10
}
.\other-script.ps1
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
finally i solve this with next code:
while(Get-Task -Status Running -Server $global:DefaultVIServer){
sleep 10
}
# Obtener la ruta del script:
$ScriptRoute = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, "Modo_mantenimiento_sprint_test.ps1"))
# Ejecutar el script en su ruta:
&"$ScriptRoute"
Thanks to all!
Regards