I am writing a powershell script with robocopy to copy "full" unc/file name paths from a list. The issue I am experiencing is that robocopy appears to be adding a \ to the end of my source paths.
I have a C:\temp\list.txt that lists the UNC paths with file names Example: \server\folder\test.txt
My Code
$Paths = Get-Content -Path C:\Temp\List.txt
ForEach ($p in $Paths) {robocopy $p "\\Server\path\path\"}
The error that powershell is throwing is :
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Monday, March 1, 2021 1:36:52 PM
Source : \\Server\path\path\test.xls\
Dest : \\Server\path\path\
Files : *.*
Options : *.* /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
2021/03/01 13:36:52 ERROR 267 (0x0000010B) Accessing Source Directory
\\Server\path\path\test.xls\
The directory name is invalid.
Does anyone know how I can stop robocopy from adding the \ at the end of my "source" location?
Thank you for your help.