Warning on filter function requiring Process block

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Ron Klimaszewski
Posts: 6
Last visit: Fri Nov 01, 2024 3:18 am

Warning on filter function requiring Process block

Post by Ron Klimaszewski »

Operating system: Windows 11
PowerShell version(s): 5.8.249

There is an incorrect warning on filter functions using pipeline values.

PSStudio_FilterFunction.jpg
PSStudio_FilterFunction.jpg (52.6 KiB) Viewed 102 times
Code: [Select all] [Expand/Collapse] [Download] (Get-AbsoluteFilePath.ps1)
  1. filter Get-AbsoluteFilePath {
  2.     [OutputType([string])]
  3.     param
  4.     (
  5.         [Parameter(Mandatory = $true,
  6.                    ValueFromPipeline = $true,
  7.                    ValueFromPipelineByPropertyName = $true)]
  8.         [ValidateNotNullOrEmpty()]
  9.         [Alias('FullName')]
  10.         [string]$FileName
  11.     )
  12.    
  13.     return "$($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($FileName))"
  14. }

Per https://learn.microsoft.com/en-us/power ... escription:
The filter keyword is used to create a type of function that runs on each object in the pipeline. A filter resembles a function with all its statements in a process block.
User avatar
brittneyr
Site Admin
Posts: 1799
Last visit: Fri Nov 01, 2024 10:29 am
Answers: 44
Been upvoted: 34 times

Re: Warning on filter function requiring Process block

Post by brittneyr »

Thank you for reporting. A bug report has been filed for our development. This issue will be addressed in the next service release.
Brittney
SAPIEN Technologies, Inc.