Powershell:使用复制项加入路径问题

时间:2011-06-24 11:21:01

标签: powershell

我有以下代码:

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

Copy-Item $fullpath "c:\"

它给了我这个输出:

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

\命令一起使用时,在完整路径中省略了初始Copy-Item字符。但是Write-Output正确打印了值。

我想加入这条道路,有人请帮助我。提前谢谢。

1 个答案:

答案 0 :(得分:0)

确保在分配变量时使用引号,以便PowerShell不会尝试执行命令

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

Copy-Item $fullpath 'c:\'
相关问题