Created
May 3, 2018 04:13
-
-
Save lazywinadmin/dfd73be86a3c05d7c6f1d8fd9cade9b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://communary.net/2015/01/12/quick-tip-determine-if-input-comes-from-the-pipeline-or-not/ | |
function Invoke-Test { | |
[CmdletBinding()] | |
param ( | |
[Parameter(ValueFromPipeline)] | |
[PSObject[]] $InputObject, | |
[Parameter()] | |
[string] $SecondParam | |
) | |
if ($PSCmdlet.MyInvocation.ExpectingInput) { | |
"Data received from pipeline input: '$($InputObject)'" | |
} | |
else { | |
"Data received from parameter input: '$($InputObject)'" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment