我正在尝试创建一个计划任务,将文件从网络驱动器复制到计算机 . 我是通过使用预定任务来做到这一点的 .

这是我的 ScheduledTaskAction

$Action = New-ScheduledTaskAction -Execute "Powershell.exe" -Argument "-command 
&{Copy-Item -Path ""$downloadDirectory"" -Destination ""$destinationDirectory"" - 
Recurse -Force}"

$downloadDirectory 是一个包含空格的路径,在我的 Copy-Item 命令中,我用 " 包装 $downloadDirectory 以修复间距问题 .

但是,我仍然得到错误: Copy-Item : A positional parameter cannot be found that accepts argument 'MyPath\HasSpace