我正在尝试创建一个powershell脚本,该脚本将文件从一个源复制到多个目标计算机上的相同路径。我在网上发现了这一点,并指出了我的测试数据,然而,我继续收到以下错误(对于它在pc_list.txt中找到的每个系统)。
脚本:
$Computers = gc "C:\Temp\Script\PC_List.txt"
$Source = "C:\Temp\Script\AAAAA.txt"
$Destination = "C$\Temp\"
foreach ($Computer in $Computers) {
Copy-Item -Path $Source -Destination "\\$Computer\$Destination\" -Recurse
}
错误:
Copy-Item : Illegal characters in path.
At line:4 char:36
+ ... Computers) {Copy-Item $Source -Destination "\\$Computer\$Destination\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.CopyItemCommand
PC_List.txt中的PC名称:
DEPT-PC1
DEPT-PC2
DEPT-PC3
谁能给我指个方向?
发布于 2018-06-07 06:38:16
BenH是正确的。虽然我在PC_List.txt中没有任何空行,但在每行的末尾确实有一个空格……接得好!
现在我看到“目标帐户名不正确”。
我想我需要添加一个$session credentials行,但需要弄清楚如何实现这一部分……
https://stackoverflow.com/questions/50729798
复制相似问题