I just converted a script from VBScript and wrote the function calls to look the same. The problem is the functions don't work as expected.
Here is my function to delete some characters I don't want from a string, and return the string back to me. I'm sure there is some very simple issue with the variable / object references that is the reason why the input string gets passed back unaltered, even if it contains spaces or single quote marks.
This function is part of a section of code which converts people's names into logon names, by removing spaces and illegal characters from the names.
function CleanString($InputStr){
$DirtyChars = "?", "/", "\", ":", "*", '", "<", ">", ",", "&", "#", "~", "%", "{", "}", "+", "_", ".", `', " "
foreach ($char in $DirtyChars)
{
$InputStr = $InputStr.Replace($char,"")
}
return $InputStr
}