From aba605f60a6f3549de5467e0194d40426882511b Mon Sep 17 00:00:00 2001 From: Tyler Hale Date: Wed, 4 Dec 2024 11:18:29 -0700 Subject: [PATCH] Initial Commit --- Remove-InvalidCharacters.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Remove-InvalidCharacters.ps1 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) +}