Description
Context:
StorSimple service contains 4 StorageAccountCredential objects, we are trying to select the first one, and use that to create a new VolumeContainer object.
Failure scenario:
$sacToUse = Get-AzureStorSimpleStorageAccountCredential | Select-Object -First 1 -Wait
$sacToUse | New-AzureStorSimpleDeviceVolumeContainer -DeviceName avirupch_app3 -Name vc_11 -BandWidthRate 256 –WaitForComplete
$sacToUse is a list of all 4 StorageAccountCredential objects instead of only the first one, and when piped to the second cmdlet it results in the latter being called once for each object, that is total 4 times.
Succeess scenario:
$sacToUse2 = (Get-AzureStorSimpleStorageAccountCredential) | Select-Object -First 1 -Wait
$sactoUse2 | New-AzureStorSimpleDeviceVolumeContainer -DeviceName avirupch_app3 -Name vc_12 -BandWidthRate 256 –WaitForComplete
After wrapping the first cmdlet in parentheses, $sacToUse2 now returns only the first object, and thus the second cmdlet is also called once.