我当前可以传输文件..但不知何故,内容被遗漏了。我认为该对象没有正确返回,但无法弄清楚。
$folder1 = "<external server>"
$folder2 = "<local path>"
# Get all files under $folder1, filter out directories
$firstFolder = Get-JFSChildItem $folder1 | Where-Object { -not $_.PsIsContainer }
$firstFolder | ForEach-Object {
# Check if the file, from $folder1, exists with the same path under $folder2
If (!(Test-Path($_.FullName.Replace($folder1, $folder2))))
{
$fileSuffix = $_.FullName.TrimStart($folder1)
Write-Host "$fileSuffix is only in folder1"
Receive-JFSItem $fileSuffix -destination $folder2
}
}错误:接收-JFSItem:没有这样的文件;没有这样的文件。
错误: Receive-JFSItem <<<< $fileSuffix -destination $folder2
发布于 2015-10-20 22:27:58
您错误地使用了TrimStart。TrimStart接受从参数中裁剪的一组符号,并且您希望将文件夹名称裁剪为从其开头开始的精确字符串。您应该将$_.fullname中的$folder1替换为空字符串。
If (!(Test-Path($_.FullName.Replace($folder1, $folder2))))
{
$fileSuffix = $_.FullName.Replace($folder1,"")
Write-Host "$fileSuffix is only in folder1"
Receive-JFSItem $fileSuffix -destination $folder2
}https://stackoverflow.com/questions/33239180
复制相似问题