Automation

 View Only
  • 1.  Wait untill New-vm is complete

    Posted Aug 29, 2023 01:46 PM

    Hi, 

    I use this for deploy my VM

    How can i wait also for VM deployment finish?
        $task = Get-ContentLibraryItem -ContentLibrary $VMTemplate.ContentLibrary -Name $VMTemplate.name |
        New-VM -Name $Computername -VMHost (Get-Cluster $VCENTER.ClusterName | Get-VMHost | Get-Random) `
        -ResourcePool (Get-Cluster $VCENTER.ClusterName).ResourcePool -Datastore $Datastore `
        -DiskStorageFormat $DiskStorageFormat -RunAsync:$true
        $task
    Wait-Task -Task  $task


  • 2.  RE: Wait untill New-vm is complete

    Posted Aug 29, 2023 05:26 PM

    The best option imho is to wait, in a loop, for the event that marks the end of the creation of the VM.
    With the Get-VIEvent cmdlet you can wait for the VMCreatedEvent.