14 lines
406 B
PowerShell
14 lines
406 B
PowerShell
Function Remove-InvalidCharacters {
|
|
[CmdletBinding()]
|
|
param (
|
|
[Parameter(Mandatory = $true)]
|
|
[string]
|
|
$String,
|
|
[Parameter(Mandatory=$false)]
|
|
$ReplacementCharacter = ''
|
|
)
|
|
|
|
$InvalidCharacters = [RegEx]::Escape(-join $([System.IO.Path]::GetInvalidFileNameChars()))
|
|
|
|
return [RegEx]::Replace($String, "[$InvalidCharacters]", $ReplacementCharacter)
|
|
}
|