If need to get rid of a charter in a string, I normally just use the replace operator. For example:
"man" -replace "n", "" # returns "ma"
But when I tried to do something like this:
"C:\Users\Public" -replace "\", ""
It just throws an error.
What can I do?
I have a script doing something in an order (handed as parameter), saving the result to a text file with the name pathlistfile.txt. So in the example I would like a name like CUsersPubliclistfile.txt. But I can't to it because I can't replace \. What to do?
PS: I already tried to escaping it "C:\Users\Public" -replace "`\", "", but that doesn't work.
". Try-replace "\\", ""