Condividi tramite


Using PowerShell to Ping Test a VM

I have been spending some time creating PowerShell snippets to help when you need to troubleshoot / debug a Hyper-V environment.  Here is a handy one-liner that I recently created:

Get-VM "File Server" | Select -ExpandProperty NetworkAdapters | Select -ExpandProperty IPAddresses | %{Ping $_}

When you run this you get the following output:

As you can see - it gets every IP address from the specified virtual machine and attempts to ping that specific IP address.  This is a quick and handy way to see if a virtual machine is up and running.

Cheers,
Ben

Comments

  • Anonymous
    May 28, 2015
    You can also use the status of the VM Integration Services via Get-VMIntegrationService and confirming the PrimaryStatusDescription is "OK".  I prefer to use the "Key-Value Pair Exchange" as that's usually the last service to start.