February 2019
Intermediate to advanced
626 pages
15h 51m
English
If a type is defined for the InputObject variable, the command will only work if the input pipeline contains that object type. An error will be thrown when a different object type is passed. The following example modifies the command to accept pipeline input from Get-Process; it expects objects of the System.Diagnostics.Process type only:
function Get-InputObject { [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipeline)] [System.Diagnostics.Process]$InputObject ) process { 'Process name {0}' -f $InputObject.Name }}
Read now
Unlock full access