Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywinadmin/dfd73be86a3c05d7c6f1d8fd9cade9b9 to your computer and use it in GitHub Desktop.
Save lazywinadmin/dfd73be86a3c05d7c6f1d8fd9cade9b9 to your computer and use it in GitHub Desktop.
#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