I have the following simple script:
$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
For some unknown reason, every time I run this script it copies the files to the correct location ($workingDir) and also copies them to $projectsDir\some subpath\something\else. I have to go delete the extra files from the other location every time this script is run.
So far I’ve tried:
- changing variable names
- specifying
-Destination "$workingDir\MyFile1.dll" - using
$null = Copy-Item -Path "...." - I even tried replacing
Copy-Itemwithxcopy.exe
and nothing changes. I put a breakpoint on the first Copy-Item command and looked at the variables – they all looked right. What’s going on here?
I rebooted my computer. Problem solved.