Get-AstLineComment¶
SYNOPSIS¶
Extracts comment tokens from a given line of PowerShell code.
SYNTAX¶
Get-AstLineComment [-Line] <String> [[-Kind] <String>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
This function parses a given line of PowerShell code and extracts comment tokens. It utilizes the PowerShell parser to analyze the input and return tokens that match the specified kind, defaulting to 'Comment'.
EXAMPLES¶
EXAMPLE 1¶
"# This is a comment" | Get-AstLineComment
Output:
Kind : Comment
Text : # This is a comment
Extracts the comment token from the input PowerShell line.
PARAMETERS¶
-Line¶
Input line of PowerShell code from which to extract the comment.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-Kind¶
The type of comment to extract.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: Comment
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¶
System.Management.Automation.Language.Token[]¶
NOTES¶
An array of tokens representing comments extracted from the input line.