Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 546

PowerShell Studio • Warning on filter function requiring Process block

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

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

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



Viewing all articles
Browse latest Browse all 546

Trending Articles