1
我目前能夠傳輸文件..但不知何故內容被遺漏。我認爲這個對象沒有被正確地返回,但無法弄清楚。 請幫忙嗎?Powershell - 從ForEach對象返回/傳輸對象
$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
}
}
錯誤:Receive-JFSItem:No such file;沒有這樣的文件。
錯誤:接收-JFSItem < < < < $ fileSuffix -destination $文件夾2
感謝,但文件的內容仍然沒有被傳輸。 錯誤:Receive-JFSItem:沒有這樣的文件;沒有這樣的文件。 錯誤:+ Receive-JFSItem <<<< $ fileSuffix -destination $ folder2 錯誤:+ CategoryInfo:NotSpecified:(:) [Receive-JFSItem],SftpException 錯誤:+ FullyQualifiedErrorId:Rebex.Net.SftpException,MVPSI.Commands .ReceiveJFSItemCommand –
如果是這樣,請更好地閱讀'Receive-JFSItem'手冊,或許它需要文件的完整名稱,並且您試圖僅爲其提供基本名稱。試試'Receive-JFSItem $ _。fullName -destination $ folder2',或者只是'$ _'。 – Vesper