0

I KNOW this sounds strange but this SIMPLE operation seems to be beyond simple:

$SourcePath = '\\remoteserver\driveletter$\path with spaces\folder'
$destpath = localdriverletter:\folder
robocopy $SourcePath $destpath /e

...and this fails with...

ERROR : No Source Directory Specified.

...and YES the path is there... NOTE: Elevation isn't the issue and the PowerShell is in Admin mode What I have to do is open explorer and drag-n-drop to ensure the sizes match.

Theo
  • 57,719
  • 8
  • 24
  • 41
Patrick Burwell
  • 129
  • 1
  • 12
  • I would think the second line should look more like this: `$destpath = "${localdriverletter}:\folder"` – Darin May 20 '22 at 19:43
  • Just realized the `$` in first line is in a weird place, so assuming driveletter is a variable: `$SourcePath = "\\remoteserver\$driveletter\path with spaces\folder"` – Darin May 20 '22 at 19:46
  • Check this answer for info on using EchoArgs for testing parameters: https://stackoverflow.com/a/71731218/4190564 – Darin May 20 '22 at 19:55

1 Answers1

0

Why are you obscuring the driveletter and localdriverletter from us? Now we have no idea if these should represent variables, but if they are, then the error is clear and all has to do with using the wrong (single) quotation marks or even none at all.

Assume you intended something like this:

$driveletter       = 'C'
$localdriverletter = 'X'

Now construct the paths using double-quotes so the variables get expanded:

$SourcePath = "\\remoteserver\$driveletter$\path with spaces\folder"
$destpath   = "${localdriverletter}:\folder"

Or use the -f Format operator:

$SourcePath = '\\{0}\{1}$\{2}' -f $remoteserver, $driveletter, 'path with spaces\folder'
$destpath   = '{0}:\folder' -f $localdriverletter
Theo
  • 57,719
  • 8
  • 24
  • 41