Ich versuche, eine Lösung Kopieren einiger Dateien von einem Ort zu einem anderen Skript ..Fehlermeldung im Skript
Ich habe eine Liste von Dateien in einem CSV-Format, mit Header
"ParentFolder, Name, FullName, lastwritetime."
Inhalt die Datei ist, die Hunderte von Zeilen hat, und verschiedene Wege, aber gleiche Laufwerksbuchstabe:
"X:\clients\A90\201AA3.05\","2012.08 RAP Proposal.xlsm","X:\clients\A90\201AA3.05\2012.08 RAP Proposal.xlsm","20/05/2016 10:41:08"
Was ich die oben genannten tun möchte, ist kopieren .. "X:\clients\A90\201AA3.05\2012.08 RAP Proposal.xlsm"
zu einem neuen Speicherort mit unterschiedlichen Laufwerk, aber gleiche Verzeichnisstruktur. Also in der CSV-Datei habe ich den Dateinamen und Pfad, aber bin mir nicht sicher, wie man das Laufwerk von dort aufteilen und eine Variable erstellen.
ich eine foreach-Schleife haben ..
$ToCopy = Import-Csv "c:\temp\log.csv"
foreach($Line in $ToCopy)
{
$FullPath = $Line.ParentFolder
$File = $Line.Name
$FullName = $Line.FullName
$file = "$FullPath\$FullName"
$DestPath = Split-Path $FullPath -NoQualifier
Copy-Item "$FullName" -Destination c:\test\$DestPath
}
Fehlermeldung, die ich erhalte ist:
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : Could not find a part of the path 'C:\test\clients\A90\Support\_index0901\'.
At line:9 char:9
+ Copy-Item "$FullName" -Destination c:\test\$DestPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
ein Charme, vielen Dank. Genau das, was ich brauchte, – yardyy