iQuadSixCore
Contributor
Contributor

Ping all VMs in an ESXi Server

Jump to solution

Hi All,

For a project of mine i need to create a script that asks for ESXi server hostname,

and after that start pinging all virtual machines that are located on this ESXi server.

I've tried to do that with no success till now.

Help Will Be Appreciated.

THANKS! Smiley Happy

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

The following relies on the fact that the VMware Tools are installed.

If they are not installed, you could adapt the script to try and ping the VM displayname.

$esxName = "MyEsx"

Get-VMHost -Name $esxName | Get-VM | %{

    $hostnamePresent = $_.Guest.HostName -ne $null

    if($hostnamePresent){

        $pingable = Test-Connection -ComputerName $_.Guest.HostName -Count 1 -Quiet

    }

    else{

        $pingable = $false

    }

    Select -InputObject $_ -Property Name,

        @{N="Hostname Present";E={$hostnamePresent}},

        @{N="Pingable";E={$pingable}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

The following relies on the fact that the VMware Tools are installed.

If they are not installed, you could adapt the script to try and ping the VM displayname.

$esxName = "MyEsx"

Get-VMHost -Name $esxName | Get-VM | %{

    $hostnamePresent = $_.Guest.HostName -ne $null

    if($hostnamePresent){

        $pingable = Test-Connection -ComputerName $_.Guest.HostName -Count 1 -Quiet

    }

    else{

        $pingable = $false

    }

    Select -InputObject $_ -Property Name,

        @{N="Hostname Present";E={$hostnamePresent}},

        @{N="Pingable";E={$pingable}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
iQuadSixCore
Contributor
Contributor

Thanks man, that exactly what i needed.Smiley Wink

0 Kudos