Copy file from network share to local machine

Welcome Forums General PowerShell Q&A Copy file from network share to local machine

Viewing 2 reply threads
  • Author
    Posts
    • #209403
      Participant
      Topics: 4
      Replies: 8
      Points: 59
      Rank: Member

      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

    • #209532
      Participant
      Topics: 4
      Replies: 82
      Points: 250
      Helping Hand
      Rank: Participant

      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

    • #209586
      Participant
      Topics: 4
      Replies: 8
      Points: 59
      Rank: Member

      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\"

      • This reply was modified 2 months, 2 weeks ago by dady48.
Viewing 2 reply threads
  • You must be logged in to reply to this topic.