-2
我正在尝试将我制作的屏幕保护程序文件复制到我们的所有桌面和便携式计算机\ system32文件夹中。我创建了一个电脑文本文件,并发现这个脚本,但我不断收到这个错误。任何帮助,将不胜感激。将大量文件复制到域计算机
在作为管理员登录的2012服务器上的Powershell 3.0中运行此操作。
$computers = gc "\\server\share\scripts\computers.txt"
$source = "\\share\scripts\MySlideshow.scr"
$dest = "C:\Windows\System32"
foreach ($computer in $computers) {
if (test-Connection -Cn $computer -quiet) {
Copy-Item $source -Destination \\$computer\$dest -Recurse
} else {
"$computer is not online"
}
}
错误:
Copy-Item : The given path's format is not supported.
At C:\users\tech\desktop\scripts\screen.ps1:6 char:9
+ Copy-Item $source -Destination \\$computer\$dest -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], NotSupportedException
+ FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.CopyItemCommand
不应该是'$ source ='\\ server01 \ share \ scripts \ MySlideshow.scr''? – TheMadTechnician
'\\ $ computer \ $ dest'将不起作用,因为它不是有效的路径名。 (如果计算机是'\\ Test',则会导致'\\ Test \ C:\ Windows \ System32',这是非法的。在UNC路径名中不能有嵌入的':'。) –