大家好:这就是我要做的......拿一个结果集(例如listoffailedcomputers.txt)并对结果集中的每个项目运行一个复制命令.逻辑是在failedlistofcomputers.txt中的所有计算机上运行复制命令,以便最终结果将该文件夹本地复制到该列表上的所有计算机上.我可以通过在所有这些计算机上使用远程控制台来实现这一点,但这样做效率不高.谢谢.
这是我到目前为止写的代码.......
$failedcomputers = gc c:\listoffailedcomputers.txt
foreach ($failedcomputer in $failedcomputers)
{
$failedcomputer | copy-item \\server\patch\*.* -destination c:\patch\
}
Run Code Online (Sandbox Code Playgroud)
这就是我得到的错误......
Copy-Item : The input object cannot be bound to any parameters for the command
either because the command does not take pipeline input or the input and its
properties do not match any of the parameters that take pipeline input.
At copypatchtofailedcomputers.ps
+ $failedcomputer | copy-item <<<< \\server\patch\ -destination c:\patch\
+ CategoryInfo : InvalidArgument: (mycomputername:PSObject) [Copy-
Item], …Run Code Online (Sandbox Code Playgroud)