我有以下简单的脚本:
$workingDir = "C:\foo\bar"
$projectsDir = "C:\foo"
Copy-Item -Path "$projectsDir\some subpath\MyFile1.dll" -Destination $workingDir
Copy-Item -Path "$projectsDir\somewhere else\MyFile2.dll" -Destination $workingDir
Copy-Item -Path "$projectsDir\another place\MyFile3.dll" -Destination $workingDir
出于某种未知原因,每次我运行此脚本时,它都会将文件复制到正确的位置 ( $workingDir
) ,并将它们复制到$projectsDir\some subpath\something\else
. 每次运行此脚本时,我都必须从其他位置删除多余的文件。
到目前为止,我已经尝试过:
- 改变变量名
- 指定
-Destination "$workingDir\MyFile1.dll"
- 使用
$null = Copy-Item -Path "...."
- 我什至尝试
Copy-Item
用xcopy.exe
什么都没有改变。我在第一个 Copy-Item 命令上设置了一个断点并查看了变量——它们看起来都正确。这里发生了什么?