Hi Experts,
I run this code and it didn't return any error:
$esxcli2 = Get-ESXCLI -VMHost host01.lab.com -V2
$arguments = $esxcli2.network.diag.ping.CreateArgs()
$arguments.host = "10.10.10.10"
$arguments.count = 3
$esxcli2.network.diag.ping.Invoke($arguments)
How do I verify the result?
Hello, troyemc-
If you grab the result of having invoked that method, you can check the Summary property of the return to see info about the ping requests. Like:
$oReturn = $esxcli2.network.diag.ping.Invoke($arguments)
$oReturn.Summary
Duplicated : 0
HostAddr : 10.10.10.10
PacketLost : 0
Recieved : 3
RoundtripAvg : 334
RoundtripAvgMS : 0
RoundtripMax : 393
RoundtripMaxMS : 0
RoundtripMin : 298
RoundtripMinMS : 0
Transmitted : 3
So, you could check whatever things are important to you -- that none were lost, that the latency was acceptable, etc. That help?
Hello, troyemc-
If you grab the result of having invoked that method, you can check the Summary property of the return to see info about the ping requests. Like:
$oReturn = $esxcli2.network.diag.ping.Invoke($arguments)
$oReturn.Summary
Duplicated : 0
HostAddr : 10.10.10.10
PacketLost : 0
Recieved : 3
RoundtripAvg : 334
RoundtripAvgMS : 0
RoundtripMax : 393
RoundtripMaxMS : 0
RoundtripMin : 298
RoundtripMinMS : 0
Transmitted : 3
So, you could check whatever things are important to you -- that none were lost, that the latency was acceptable, etc. That help?
Thank so much mattboren!!! This is exactly what I was looking for.
I was hoping to get some help on this one too. I entered the exact same code as did the original poster, but I get the following error.
$esxcli2 = Get-EsxCli -VMHost (Get-VMHost | select -First 1) -V2
$arguments = $esxcli2.network.diag.ping.CreateArgs()
$arguments.Count = 2
$arguments.host = "x.x.x.x"
$esxcli2.network.diag.ping.Invoke($arguments)
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
At C:\Users\\Documents\practice.ps1:5 char:1
+ $esxcli2.network.diag.ping.Invoke($arguments)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], FormatException
+ FullyQualifiedErrorId : System.FormatException
Thank you for your time.
Bad choice of variable name ($arguments).
Use another name, then it should work
$pingArg = $esxcli2.network.diag.ping.CreateArgs()
$pingArg.count = 2
$pingArg.host = "192.168.10.2"
$esxcli2.network.diag.ping.Invoke($pingArg)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your help.
two things helped.
1. changing "Count" to "count" I guess it is case sensitive.
2. Then adding the "$oReturn". I was only getting VMware gibberish before I added the "| Format-List".
$esxcli2 = Get-EsxCli -VMHost (Get-VMHost | select -First 1) -V2
$arguments = $esxcli2.network.diag.ping.CreateArgs()
$arguments.count = 2
$arguments.host = "x.x.x.x"
$esxcli2.network.diag.ping.Invoke($arguments)
$oReturn = $esxcli2.network.diag.ping.Invoke($arguments)
$oReturn.Summary | Format-List