Quantcast
Channel: TechNet Technology News
Viewing all articles
Browse latest Browse all 13502

PowerShell snippet: “start a virtual machine and wait for a bit”

$
0
0

Over the last year there are a couple of PowerShell functions that have become a common set of many of my scripts.  One example is this “StartVMAndWait” function:

function StartVMAndWait($vmToStart){
start-vm $vmToStart
do {Start-Sleep -milliseconds 100} 
    until ((Get-VMIntegrationService $vmToStart | ?{$_.name -eq"Heartbeat"}).PrimaryStatusDescription -eq"OK")
}

This is a simple function that starts a virtual machine and then waits until the heartbeat integration component has returned a healthy status.  This is a good indicator that the guest operating system has completed booting – which makes this quite handy when you want to start a virtual machine and then interact with the guest operating system in some way.

Cheers,
Ben


Viewing all articles
Browse latest Browse all 13502

Trending Articles



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