Copy file from network share to local machine

Hi,

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

$Uname = $env:UserName
$Source = "\\172.30.168.250\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 \172.30.168.250\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. https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Management/New-Item?view=powershell-5.1

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::\172.30.168.250\Sources\SAPUILandscape.xml” -Destination “Microsoft.PowerShell.Core\FileSystem::C:\Users$Uname\AppData\Roaming\sap\common”