Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Repost] PSUseProcessBlockForPipelineCommand does not recognize use of $input within an End block #1915

Open
brianary opened this issue May 17, 2023 · 1 comment

Comments

@brianary
Copy link

Repost: Hoping to get some clarification, since this was mechanically closed based on a factually incorrect response to #1912 .

Steps to reproduce

Invoke-ScriptAnalyzer -IncludeRule PSUseProcessBlockForPipelineCommand `
	-ScriptDefinition 'Param([Parameter(ValueFromPipeline=$true)][psobject] $Item); End {$input |ConvertTo-Json}'

Expected behavior

(no output)

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSUseProcessBlockForPipelineCommand Warning                 1     Command accepts pipeline input but has not defined a
                                                                  process block.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
@brianary
Copy link
Author

From the documentation for $input:

In the end block, the $input variable enumerates the collection of all input to the function.

Note

You can't use the $input variable inside both the process block and the end block in the same function or script block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants