Copy file from network share to local machine


I can’t figure it out. i have this code:

$Uname = $env:UserName
$Source = "\\\Sources\SAPUILandscape.xml"
$Destination = "C:\Users\$Uname\AppData\Roaming\sap\common\"
Copy-Item –Path $Source –Destination $Destination


I’m getting this error:

Copy-Item : Cannot find path ‘C:\Users\dady\ג€Path \\Sources\SAPUILandscape.xml ג€Destination’ because it does not exist.
At C:\Users\dady\Desktop\SapGui.ps1:17 char:1

  • Copy-Item ג€“Path $Source ג€“Destination $Destination
  • CategoryInfo : ObjectNotFound: (C:\Users\dady\ג…l ג€Destination:String) [Copy-Item], ItemNotFoundException
  • FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand


What i’m not doing right?


Thanks in advance

There are some weird characters in your error message. My guess is that is an environment difference (language). At any rate, the error message is simply saying the destination path doesn’t exist so this is not an issue with your code necessarily, but the path simply doesn’t exist. If you need to create the path, you can do that with New-Item.

Thanks Mike for your reply. I also saw this weird characters and i have no clue where they are coming from.
I manged solving my issue with this code:


$Uname = $env:UserName
Copy-Item -Path “Microsoft.PowerShell.Core\FileSystem::\\Sources\SAPUILandscape.xml” -Destination "Microsoft.PowerShell.Core\FileSystem::C:\Users$Uname\AppData\Roaming\sap\common"