Is there a way to use a variable whose value contains the colon character as a filename string in a command-line redirect? Powershell always treats the colon as a drive separator, regardless of escape characters. How can this be done using the colon as a character literal contained in the output filename?
$colonVar = "Colon:string" echo "fileContents" > "file$colonVar.txt"
Cannot find drive. A drive with the name 'fileColon' does not exist.
Can we instead write "fileContents" to a file named "fileColon:string.txt"?
I have not been successful using any combination of single or double quotation marks, escape characters, parentheses, or dollar sign and parentheses in the string value or the redirect string. The portion of the string after the colon is always treated as a drive.
(Using Powershell 2.0)