【发布时间】:2017-11-20 11:13:14
【问题描述】:
我想使用 powershell 复制目录中的文件列表:
$Dest="C:\temp"
$Fiches = ls -File '\\srv\share$\fiche*.pdf' #Fiches contains the list of all fiche*.pdf
foreach($Fiche in $Fiches){
Copy-Item $Fiche $Dest #send me an error : "syntaxe incorrect" with this line underlined
}
有什么想法吗? (我的文件名包含空格)
【问题讨论】:
-
粘贴确切的错误
-
Copy-Item : 文件名语法或目录不正确。 Au caractère \\SRV\share\myscript.ps1:6 : 5 + Copy-Item $Fiche $Dest + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified : (:) [Copy-Item], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
-
我的分享包含$。这应该是问题所在。 \\srv\data$\
-
使用
-LiteralPath参数 -
相同结果:
Copy-Item -LiteralPath $Fiche $Dest
标签: powershell copy copy-item