不能将文件复制到“test-Path”可以看到的path

这是我迄今为止。 我收到消息

复制项目:path中的非法字符。

我试图在每个工作站(`89)上创build一个目录,将工作站上的现有文件复制到该文件夹​​,然后将新文件复制到指定的path。 当我注释掉所有与复制有关的事情时,只要validationpath,path就会恢复为有效。

我尝试使用batch file在SCCM(2007)中通过as / w push来部署这些文件,但由于path未find/无效path错误,因为Trnsport之间的(称为中间点)而Trns

 $file = "\\path\to\files\ITClientBuild\Specs2\specslas5\testcopy.txt" $outfile = "c:\temp\las6copy.csv" gc c:\temp\las6.txt | %{ $computer = $_ $ping = Test-Connection $computer -Count 2 -Quiet if ($ping) { $pathTest1 = Test-Path "\\$computer\c$\Program Files\AASHTOWare\Trns·port Client-Server PES-LAS" $pathTest2 = Test-Path "\\$computer\c$\Program Files (x86)\AASHTOWare\Trns·port Client-Server PES-LAS" if($pathTest1 -eq $true){ # md -Force "\\$computer\c$\windows\temp\las5a" # cp -force "\\$computer\c$\Program Files\AASHTOWare\Trns·port Client-Server PES-LAS\las6cust.pbd" "\\$computer\c$\windows\temp\las5\*" cp -force $file "\\$computer\\c$\\Program Files\\AASHTOWare\\Trns·port Client-Server PES-LAS\\*" "$computer FILE PUSHED to PES-LAS dir" >> $outfile } else { "$computer las6 PATH DOES NOT EXIST!!" >> $outfile } if ($pathTest2 -eq $true){ # md -Force "\\$computer\c$\windows\temp\las5a" # cp -force "\\$computer\c$\Program Files (x86)\AASHTOWare\Trns·port Client-Server PES-LAS\las6cust.pbd" "\\$computer\c$\windows\temp\las5\*" cp -force $file "\\$computer\c$\Program Files (x86)\AASHTOWare\Trns·port Client-Server PES-LAS\*" "$computer FILE PUSHED to PES-LAS dir" >> $outfile } else { "$computer PES-LAS PATH DOES NOT EXIST!!" >> $outfile } } else { "$computer OFFLINE" >> $outfile } } 

错误发生是因为你的目的地不应该有\* 。 尝试没有这个,它应该完成没有问题。

 cp -force $file "\\$computer\c$\Program Files (x86)\AASHTOWare\Trns·port Client-server PES-LAS"