When copying files from source root, it seems that ROBOCOPY see the file(s) as directories and the resoult is, that the filename become a directoiry name on target
Logfile says:
2023/03/08 11:16:09 ERROR 267 (0x0000010B) Accessing Source Directory \XXXXXXXXXX\mdt$\Placer IKKE l›se filer i hovedshare - Vedr_backup_VIGTIGT.txt\
The directory name is invalid.
How can I prevent that
My code:
$FileName = (Get-Date).tostring("MM-dd-yyyy---HH-mm-ss")
$oldpaths = Get-ChildItem "\XXXXXXXXXX\mdt$\*"
$newpath = 'Q:\CTXMDT'
Set-Location $newpath
foreach($oldpath in $oldpaths)
{
$newpath1 = $newpath + $oldpath.Name
mkdir $newpath1 -ErrorAction Ignore > $null
robocopy $oldpath $newpath1 /Z /MT:16 /MIR /W:0 /R:0 /V /TS /FP /PF /E /FFT /XO /SEC /XD ".snapshots" /XD "$RECYCLE.BIN" | Out-File D:\Logfiler\XXXXXXXXXX_MDT"$FileName MDT.log" -Append
Write-Host "$oldpath has been copiet to $newpath1"
}
Best regards
MACH