Get-AstFunctionType¶
SYNOPSIS¶
Retrieves the type of an abstract syntax tree (Ast) function.
SYNTAX¶
Path¶
Get-AstFunctionType [-Name <String>] -Path <String> [-Recurse] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Script¶
Get-AstFunctionType [-Name <String>] -Script <String> [-Recurse] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
Parses a PowerShell script file or script content to determine the type of function present.
The function classifies functions as Function
, Filter
, Workflow
, or Configuration
.
It supports searching for specific function names and can process nested functions if required.
EXAMPLES¶
EXAMPLE 1¶
Get-AstFunctionType -Path "C:\Scripts\MyScript.ps1"
Output:
Name Type
---- ----
Test1 Function
Test2 Filter
Parses the specified script file and identifies function types.
EXAMPLE 2¶
Get-AstFunctionType -Script "function Test { param() Write-Output 'Hello' }"
Output:
Name Type
---- ----
Test Function
Parses the provided script content and determines the function type.
PARAMETERS¶
-Name¶
The name of the command to search for. Defaults to all commands ('*').
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: *
Accept pipeline input: False
Accept wildcard characters: False
-Path¶
The path to the PowerShell script file to be parsed. Validate using Test-Path
Type: String
Parameter Sets: Path
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
-Script¶
The PowerShell script to be parsed.
Type: String
Parameter Sets: Script
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
-Recurse¶
Search nested functions and script block expressions.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
OUTPUTS¶
PSCustomObject¶
NOTES¶
Represents the function name and its determined type.
RELATED LINKS¶
https://psmodule.io/Ast/Functions/Functions/Get-AstFunctionType/