Input object types

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
}
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.88.249