I was building a piece of PowerCLU code to check on my vCD Deployed vAPPs for certain errors and because it’s me I was curious what performance difference there was between using array based operations verses piped operations in powershell. Here’s what I found out.
Here is the array based operation – time to completion 2 minutes 30 seconds.
$myVAPP = @(Get-CIVApp | Select-Object Org, Name, Status)
foreach ($myVAPP.Name in $myVAPP)
{
IF ($myVAPP.Status -eq "FailedCreation")
{
Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
}
ELSE
{
IF ($myVAPP.Status -eq "Unresolved")
{
Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
}
else
{
IF ($myVAPP.Status -eq "Unknown")
{
Write-Host 'vAPP' $myVAPP.Name' - Status is' $myVAPP.Status
}
else
{
}
}
}
}
Here is the pipe based operation which is recommended for reasons that I now can testify for first hand.
Get-CIVApp -Status "Unresolved", "FailedCreation", "Unknown", "Unrecognized" | Select-Object Org, Name, Status
This operation returned the same results as the array based operation in 14 seconds, that’s 9% of the original time of using an array…


So there you have it, how one piece of software can tell you what is wrong, what is affected and give you an idea of what needs done to fix it. All in a real-time, efficient and intelligent manner. The entire exercise took about 5 minutes to do a complete health check on 1,700+ VMs and figure out what was wrong with the one that I have covered here. If I can do the math right that means I did a complete health check on my environment at a rate of 586 VMs a second (totally ignoring the hosts and storage which were also checked) to figure out if I had an issue... and within a minute knew what was wrong with the VM having an issue... now that is pretty awesome!