I had a reason to do a ping sweep across a set of machines with vCenter using PowerCLI. The Test-Connection cmdlet is available on Win 8 / Win 2012 R2. Enjoy.
# Assuming you’ve loaded the PowerCLI snapin located @
# http://blogs.vmware.com/PowerCLI/2014/09/new-release-vmware-vsphere-powercli-5-8-release-1.html
# Loading PowerCLI Snapins
function LoadSnapin{
param($PSSnapinName)
if (!(Get-PSSnapin | where {$_.Name -eq $PSSnapinName})){
Add-pssnapin -name $PSSnapinName
}
}
LoadSnapin -PSSnapinName “VMware.VimAutomation.Core”
#An account is needed
$cred = Get-Credential “domainuser”
#Connect to vCenter
Connect-VIServer -server “vCenterServer” -credential $cred
$a = Get-Cluster “Server-Cluster-Name” | get-vm
$results = @()
foreach($computer in $a)
{
Write-Host $Computer.Name
$results += Test-Connection -ComputerName $Computer.Name -count 2
}
$results | Select Address,IPV4Address,ReplySize,ResponseTime | Export-Csv results.csv
Here is a sample output
#TYPE Selected.System.Management.ManagementObject
“Address”,”IPV4Address”,”ReplySize”,”ResponseTime”
“Server1″,”192.168.10.50″,”32″,”0″
“Server1″,”192.168.10.50″,”32″,”0″
“Server2″,”192.168.11.70″,”32″,”0″
“Server2″,”192.168.11.70″,”32″,”0″