Unable to Copy item from UNC path to destination using $en:programfiles \ (86)

Welcome Forums General PowerShell Q&A Unable to Copy item from UNC path to destination using $en:programfiles \ (86)

Viewing 6 reply threads
  • Author
    Posts
    • #220989
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member
      " -Path "$Path" -MaxStage $MaxStage" If ($ValidateOnly) { $ArgumentList = $ArgumentList + " -ValidateOnly" } If ($SkipValidation) { $ArgumentList = $ArgumentList + " -SkipValidation $SkipValidation" } If ($Mode) { $ArgumentList = $ArgumentList + " -Mode $Mode" } Write-Host "elevating" Start-Process powershell.exe -Verb RunAs -ArgumentList ($ArgumentList -f ($myinvocation.MyCommand.Definition)) -Wait Exit } #Set-ExecutionPolicy -Scope CurrentUser -Confirm Unrestricted -Verbose ##Locate the msi files for silent execution## $CurrentLocation = Split-Path -Parent $MyInvocation.MyCommand.Path; ##To install the Espera## $msiinstall = @("/i", "EsperaClientSetup.msi", "/q", "/norestart", "/l*v","$env:windir\Temp\espera.log") Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" -ArgumentList $msiinstall -Wait -WorkingDirectory $CurrentLocation ##Check IP address to determine which XML file to install $IP = ((ipconfig | findstr [0-9].\.)[0]).Split()[-1] If('$IP' -like "10.10.*.*") { Copy-Item '.\Thh\EsperaClient.exe.config' -Destination "$env:programfiles(x86)"\Advatel\Espera Client\bin -Recurse -Force }Else { Write-host "Espera Installed" } stop-process -Id $PID [/crayon]
    • #220992
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member

      LINE 48 is where i am having issues with copying from the unc path to destination. I think the issue is the destination part.

    • #220998
      Participant
      Topics: 10
      Replies: 2481
      Points: 6,543
      Helping Hand
      Rank: Community MVP
    • #221010
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member

      I have tried that with no luck 🙁

    • #221016
      Participant
      Topics: 10
      Replies: 2481
      Points: 6,543
      Helping Hand
      Rank: Community MVP

      I have tried that with no luck 🙁

      Do you get errors? … I tried it and it outputs exactly the expected result. Did you notice – there is no Dollar sign inside the curly braces. 😉

    • #221031
      Participant
      Topics: 4
      Replies: 10
      Points: 51
      Rank: Member

      Yeah it looks like permissions

      Copy-Item : Access to the path ‘C:\Program Files (x86)\Advatel\Espera Client\bin\EsperaClient.exe.config’ is denied.
      At line:1 char:1
      + Copy-Item ‘.\Thh\EsperaClient.exe.config’ -destination “${env:program …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : PermissionDenied: (\\tpin01\it_dat…ient.exe.config:FileInfo) [Copy-Item], UnauthorizedAccessException
      + FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand

      Copy-Item : Access to the path ‘C:\Program Files (x86)\Advatel\Espera Client\bin\EsperaClient.exe.config’ is denied.
      At line:1 char:1
      + Copy-Item ‘.\Thh\EsperaClient.exe.config’ -destination “${env:program …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
      + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand

    • #221040
      Participant
      Topics: 10
      Replies: 2481
      Points: 6,543
      Helping Hand
      Rank: Community MVP

      Yeah it looks like permissions

      So your issue is not your Powershell code it is your lack of rights to the target folder. 😉

Viewing 6 reply threads
  • The topic ‘Unable to Copy item from UNC path to destination using $en:programfiles \ (86)’ is closed to new replies.