| external help file | PSPublishModule-help.xml |
|---|---|
| Module Name | PSPublishModule |
| online version | https://github.com/EvotecIT/PSPublishModule |
| schema | 2.0.0 |
Removes PowerShell comments from a script file or provided content, with optional empty-line normalization.
Remove-Comments -SourceFilePath <string> [-DestinationFilePath <string>] [-RemoveAllEmptyLines] [-RemoveEmptyLines] [-RemoveCommentsInParamBlock] [-RemoveCommentsBeforeParamBlock] [-DoNotRemoveSignatureBlock] [<CommonParameters>]Remove-Comments -Content <string> [-DestinationFilePath <string>] [-RemoveAllEmptyLines] [-RemoveEmptyLines] [-RemoveCommentsInParamBlock] [-RemoveCommentsBeforeParamBlock] [-DoNotRemoveSignatureBlock] [<CommonParameters>]Uses the PowerShell parser (AST) to remove comments safely rather than relying on fragile regex-only approaches. Useful as a preprocessing step when producing merged/packed scripts.
PS> Remove-Comments -SourceFilePath '.\Public\Get-Thing.ps1' -DestinationFilePath '.\Public\Get-Thing.nocomments.ps1'Writes the cleaned content to the destination file.
PS> $clean = Remove-Comments -Content (Get-Content -Raw .\script.ps1)Returns the processed content when no destination file is specified.
Raw file content to process.
Type: String
Parameter Sets: Content
Aliases: None
Possible values:
Required: True
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueFile path to the destination file. If not provided, the content is returned.
Type: String
Parameter Sets: FilePath, Content
Aliases: Destination, OutputFile, OutputFilePath
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueDo not remove a signature block, if present.
Type: SwitchParameter
Parameter Sets: FilePath, Content
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueRemove all empty lines from the content.
Type: SwitchParameter
Parameter Sets: FilePath, Content
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueRemove comments before the param block. By default comments before the param block are not removed.
Type: SwitchParameter
Parameter Sets: FilePath, Content
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueRemove comments in the param block. By default comments in the param block are not removed.
Type: SwitchParameter
Parameter Sets: FilePath, Content
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueRemove empty lines if more than one empty line is found.
Type: SwitchParameter
Parameter Sets: FilePath, Content
Aliases: None
Possible values:
Required: False
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueFile path to the source file.
Type: String
Parameter Sets: FilePath
Aliases: FilePath, Path, LiteralPath
Possible values:
Required: True
Position: named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
None
System.Object
- None