Starting with our SDK version 2, we now have many of our PowerShell cmdlets that allow pipelines to be created. To determine if a cmdlet accepts pipelines for any of it's parameters, you will need to examine the Help context for that particular cmdlet. To do this, perform the following command, replacing the New-Pfa2Host with the cmdlet of your choice.
Get-Help -Name New-Pfa2Host -Parameter *
The output from that command will show you all of the parameters allowed for that cmdlet and what objects those parameters allow and disallow. This is an excerpt of that output showing both a parameter called
-Iqns that shows an
Accept pipeline input: False, as well as a parameter called
-Name that does allow for pipeline input:
-Iqns <List<String>>
The iSCSI qualified name (IQN) associated with the host.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Name <String>
Performs the operation on the unique name specified.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName, ByValue)
Accept wildcard characters? false
This means that when we want to use the New-Pfa2Host cmdlet for reporting on or executing commands against multiple hosts in an array, we can pipeline multiple
-Names to it without having to specify each one. This would be an example of a pipeline that sends an array of names to the New-Pfa2Host cmdlet like this:
$Hosts = @("host01","host02","host03")
$Hosts | New-Pfa2Host -Array $array
Here is another example of a pipeline using the Get-Pfa2Host cmdlet and piping the output to the Remove-Pfa2Host cmdlet, effectvely removing all of the hosts on the array (this is a destructive command and should only be used when necessary).
Get-Pfa2Host -Array $array | Remove-Pfa2Host -Array $array
As you can see from these few examples, with the addition of pipelines in the SDK, you can accomplish more with less and produce more desirable output. For more examples, please see the Readme.md file included with the module.