Get-LineComment¶
SYNOPSIS¶
Extracts the inline comment from a single line of PowerShell code.
SYNTAX¶
Get-LineComment [-Line] <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION¶
Parses a given line of PowerShell code and extracts any inline comment. If an inline comment exists, the function returns the comment text; otherwise, it returns nothing.
EXAMPLES¶
EXAMPLE 1¶
'Get-Process # This retrieves all processes' | Get-LineComment
Returns: '# This retrieves all processes'
EXAMPLE 2¶
'Write-Host "Hello World"' | Get-LineComment
Returns: $null (no comment found)
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
-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.