Link to home
Create AccountLog in
Avatar of CaussyR
CaussyR

asked on

Copy a file to several remotw servers in the same domain

I need to copy a single file to approximately 50 servers. I want to use PowerShell to do this and tried the following :

$ServerList=IMPORT-CSV D:\temp\BGInfo\ServerList.csv

foreach ($Server in $ServerList)
{
Copy-Item -path 'd:\temp\bginfo\2K8Server_Default.bgi' -Destination “\\$_\C$\BGINFO” -force
}

When I run it, I see the following error message :

Copy-Item : The network path was not found.
At line:5 char:1
+ Copy-Item -path 'd:\temp\bginfo\2K8Server_Default.bgi' -Destination “\\$_\C$\BGI ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

Can anyone help me resolve this issue.

Thanks.
Avatar of SubSun
SubSun
Flag of India image

Try..
$ServerList=IMPORT-CSV D:\temp\BGInfo\ServerList.csv

foreach ($Server in $ServerList)
{
Copy-Item -path 'd:\temp\bginfo\2K8Server_Default.bgi' -Destination “\\$($Server)\C$\BGINFO” -force
}

Open in new window

Avatar of CaussyR
CaussyR

ASKER

Thanks for your reply,  but when I run the script I still see the following : Copy-Item : The network path was not found.

The network path does exist as I have browsed to each location.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer