-1

I typed this:

$folder = 'c:\test'
"c:\test" -replace $folder ""

but get this error:

At line:1 char:25
+ "c:\test" -replace $folder ""
+                         ~~
Unexpected token '""' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

This doesn't help me How to handle backslash character in PowerShell -replace string operations?

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
user310291
  • 36,946
  • 82
  • 271
  • 487

1 Answers1

1

You are missing a comma and I think you have your input string and search string backwards.

$folder -replace "test",""
UnhandledExcepSean
  • 12,504
  • 2
  • 35
  • 51