Remove-InvalidFileNameChars
SYNOPSIS
Remove invalid characters from the supplied string.
SYNTAX
Remove-InvalidFileNameChars [-Name] <String> [<CommonParameters>]
DESCRIPTION
Remove invalid characters from the supplied string and returns a valid filename as a string.
EXAMPLES
EXAMPLE 1
Remove-InvalidFileNameChars -Name "Filename/\1"
PARAMETERS
-Name
Text to remove invalid filename characters from.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
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
System.String
A string containing invalid filename characters.
OUTPUTS
System.String
Returns the input string with the invalid characters removed.
NOTES
This functions always returns a string however it can be empty if the name only contains invalid characters. Do no use this command for an entire path as '' is not a valid filename character.