VMware Cloud Community
iQuadSixCore
Contributor
Contributor
Jump to solution

Ping all VMs in an ESXi Server

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
iQuadSixCore
Contributor
Contributor
Jump to solution

Thanks man, that exactly what i needed.Smiley Wink

Reply
0 Kudos