PowerShell 替换文件夹名称

PowerShell Replace Folder Name

我正在尝试将一些文件从构建服务器复制到 TFS 构建中的暂存服务器。为此,我在 vNext 构建中使用 PowerShell 脚本(单步)。但是,我无法让 -replace 工作。

当我在 ISE 客户端运行以下

[string] $thing0 = "K:\a\b\c"
[string] $thing1 = "$/Thing/Branch/Folder/Filename.ps1"
[string] $thing2 = $thing1 -replace "$/Thing/Branch/", $thing0

$thing2

$thing2 应该是 K:\a\b\c/Folder/Filename.ps1 但没有改变。我该如何着手让这个字符串替换工作?

-replace参数使用Regex搜索,其中$等字符具有特殊含义。

而是使用以下方法:

[string] $thing2 = $thing1.Replace("$/Thing/Branch/",$thing0)