Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 258290

Re: Validate free space on destination datastore

$
0
0

You could do something like this.
You can eventually ut a break in the else-block, so this message doesn't repeat for each VM still in the pipeline.

 

$source="DS03"

$destin="DS39"

 

Get-Datastore$source|Get-VM-PipelineVariable vm |

ForEach-Object-Process {

    $destDS=Get-Datastore$destin

    if($destDS.FreeSpaceGB/$destDS.CapacityGB-gt0.2){

        $task=Move-VM-VM $vm-Datastore $destin-RunAsync

        while($task.PercentComplete-ne100){

            Start-Sleep5

            $task=Get-Task-Id $task.Id

            $sProg=@{

                Activity        ="$vm Storage vMotion from $source to $destin"

                Status          ="$($task.PercentComplete)%"

                PercentComplete=([int]($task.PercentComplete))

            }

            Write-Progress@sProg

        }

    }

    else{

        Write-Host"Destination doesn't have 20% of free space"

    }

}


Viewing all articles
Browse latest Browse all 258290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>