Powershell - 从ForEach-Object返回/传输对象

时间:2015-10-20 14:18:29

标签: powershell

我目前能够传输文件..但不知何故,内容被遗漏了。我认为该对象没有正确返回,但无法弄清楚。 有什么帮助吗?

context.Response.OnSendingHeaders

错误:Receive-JFSItem:没有这样的文件;没有这样的文件。

错误:Receive-JFSItem<<<< $ fileSuffix -destination $ folder2

1 个答案:

答案 0 :(得分:1)

您错误地使用了TrimStartTrimStart接受符号集以从参数中修剪,并且您希望将文件夹名称从其开头修剪为精确字符串。您应该使用$folder1中的空字符串替换$_.fullname

If (!(Test-Path($_.FullName.Replace($folder1, $folder2))))
{
    $fileSuffix = $_.FullName.Replace($folder1,"")
    Write-Host "$fileSuffix is only in folder1"
    Receive-JFSItem $fileSuffix -destination $folder2
}