So I recently learn that to remove, say, curly braces with -replace, I need to enclose them in square brackets. Like so:
$server = '{Server123}'
$server -replace '[{}]',''
So then, my mind wondered, how would we remove square brackets?
$server1 = '[Serverxyz]'
I've tried escaping with forward slashes, back slashes, using more square brackets, parentheses, curly braces, putting each square bracket into a variable and replacing the variables.
I'm coming up with nothing. I find a couple of online sources for the procedure, but they are for doing the job in Javascript, or C++, or something besides PowerShell.