Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, October 18, 2017 6:00 AM
Hi All,
I am new to powershell I have added a node to the server and connected through psremoting command in powershell,but now i want to copy a file in remote system using a script.
Regards.
All replies (8)
Thursday, October 19, 2017 5:47 AM ✅Answered
Hi,
I agree with jrv.
You could have a try to use UNC path in Copy-Item cmdlet, the following example scripts for your reference:
Copy-Item -Path '\\server1\C$\file.txt' -Destination '\\server2\D$\file.txt'
In addition, you might also refer to the following links for copying to or from a PowerShell session. Hope it is helpful to you:
Copy To or From a PowerShell Session
https://blogs.technet.microsoft.com/poshchap/2015/10/30/copy-to-or-from-a-powershell-session/
If you need further help, please feel free to let us know.
Best Regards,
Albert Ling
Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Thursday, October 19, 2017 6:53 AM ✅Answered
You do not need a session. Sessions are useful when crossing domains and using multiple sets fo credentials.
Copy-item \server1\c$\folder\file.ext \server2\c$\otherfolder\file.ext
That is all you need to do.
\(ツ)_/
Wednesday, October 18, 2017 6:36 AM
Copy-Item will copy files anywhere without remoting.
Please don't cover you posts with colors or dark blots. It is unreadable with most browsers.
\(ツ)_/
Tuesday, October 24, 2017 2:25 AM
Hi,
Just checking in to see if the information provided was helpful.
Please let us know if you would like further assistance.
Best Regards,
Albert Ling
Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Tuesday, October 24, 2017 10:47 AM
Hi Albert and JRV,
Thank you so much for you concern.
It really helpful for me .
Regards.
Tuesday, October 24, 2017 10:59 AM
Hi All,
Now i can able to connect to remote system and can copy the files easily
Now i want to copy the file to 3 servers at a time.
1) Could you plz tell me command how can i add 3 servers to my main server
2) And also want to know is there any script to copy the file from main server to remote servers at a time.
Regards.
Tuesday, October 24, 2017 11:00 AM
Hi All,
Now i can able to connect to remote system and can copy the files easily
Now i want to copy the file to 3 servers at a time.
1) Could you plz tell me command how can i add 3 servers to my main server
2) And also want to know is there any script to copy the file from main server to 3 remote servers at a time.
Regards.
Wednesday, October 25, 2017 7:05 AM
Hi,
Based on my research, you could have a try with the following scripts. Hope it is helpful to you:
$destinations = '\\server1\share', '\\server2\share', '\\server3\share'
foreach ($destination in $destinations)
{
Copy-Item -Path '\\server\share\test.txt' -Destination $destination
}
If you need further help, please feel free to let us know.
Best Regards,
Albert Ling
Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].