Quantcast
Viewing all articles
Browse latest Browse all 311

PowerShell Studio • Warning on filter function requiring Process block

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

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

Image may be NSFW.
Clik here to view.
PSStudio_FilterFunction.jpg

Code:

filter Get-AbsoluteFilePath {
[OutputType([string])]
param
(
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias('FullName')]
[string]$FileName
)

return "$($ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($FileName))"
}

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.

Statistics: Posted by Ron Klimaszewski — Thu Oct 24, 2024 7:54 am — Replies 1 — Views 12



Viewing all articles
Browse latest Browse all 311

Trending Articles