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!
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
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
Thanks man, that exactly what i needed.