Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

powershell copy files into remote machine issue using Copy_Item cmdlet

I was trying to copy few files into my remote box, but i see the path format is not correct issue, can someone chekc this?

for($hostname in Get-Content C:\folder1\machine.txt){
Copy-Item -Path "C:\folder1\ramen-0.1-web-1.3.6.jar" -Destination "\\hostname\C:\folder1\folder2\" -Recurse -Force

}

Error Message is:
Copy-Item : The given path’s format is not supported.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Your missing ‘$’ sign. Your are using ‘c:’ as part of your destination path.

for($hostname in Get-Content C:\folder1\machine.txt){
Copy-Item -Path "C:\folder1\ramen-0.1-web-1.3.6.jar" -Destination "\\hostname\C$\folder1\folder2\" -Recurse -Force

}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading