我输入了这个:
$folder = 'c:\test'
"c:\test" -replace $folder ""
但得到这个错误:
At line:1 char:25 + "c:\test" -replace $folder "" + ~~ Unexpected token '""' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken
这对我没有帮助How to handle backslash character in PowerShell -replace string operations?
您缺少一个逗号,我认为您的输入字符串和搜索字符串向后。
$folder -replace "test",""