commit aba605f60a6f3549de5467e0194d40426882511b Author: Tyler Hale Date: Wed Dec 4 11:18:29 2024 -0700 Initial Commit diff --git a/Remove-InvalidCharacters.ps1 b/Remove-InvalidCharacters.ps1 new file mode 100644 index 0000000..6bd6780 --- /dev/null +++ b/Remove-InvalidCharacters.ps1 @@ -0,0 +1,14 @@ +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) +}