开发者

Powershell: Join path issues with copy item

I have the following piece of code:

$ServerPath = \\test\ps
$fullpath = Join-Path $ServerPath "\stackoverflow"

Copy-Item $fullpath "c:\"

It gives me this output:

Cannot find path \test\ps\stackoverflow because it doesn't exist.

Inital \ character is omitted in full path when used with Copy-Item command. but Write-Output prints value correct开发者_运维问答ly.`

I want to join the path, someone please help me with this. Thanks in advance.


Be sure to use quotes when assigning a variable so that PowerShell does not try to execute the command

$ServerPath = '\\test\ps'
$fullpath = Join-Path $ServerPath '\stackoverflow'

Copy-Item $fullpath 'c:\'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜