Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Copy-Item UNC problem

$
0
0

Hi there,

This is my first post. Ran into a small problem I simply can't resolve. Code:

$comp = Read-Host "Enter PC-name: "
$from = "\\server01\Folder name\Versions\Script\File.exe"
$to = "\\" + $comp + "\" + "c$" + "\Folder\Folder"

if(test-path $from){
    Copy-Item -path @from -destination $to -force
    pause
}else{
    Write-Host "No such path."
}

I get the error: Copy-Item : A positional parameter cannot be found that accepts argument '\'.

Entering the UNC path in explorer works and have the write rights. After some research I found out it might have something to do with spaces in in folder names on a unc path OR using "$c" in the path. Tried a lot but nothing works. Any ideas?


Viewing all articles
Browse latest Browse all 6937

Trending Articles