powershell - Mass file copy to domain computers -
i trying take screen saver file i've made , re-create of our desktops , laptops \system32 folder. created computers text file , found script, maintain getting error. help appreciated.
running in powershell 3.0 on 2012 server logged in admin.
$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 not online" } } error:
copy-item : given path's format not supported. @ 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
the resulting unc format destination invalid. you're passing
"\\computer\c:\windows\system32" when should passing
"\\computer\c$\windows\system32" try quoting -destination parameter too:
copy-item $source -destination "\\$computer\$dest" -recurse you'll need utilize single-quotes when assigning $dest prevent powershell trying expand dollar sign variable sigil.
$dest = 'c$\windows\system32' debug script using copy-item -whatif ... ensure you're passing right parameters.
powershell unc
No comments:
Post a Comment