Welcome › Forums › General PowerShell Q&A › Unable to Copy item from UNC path to destination using $en:programfiles \ (86)
- This topic has 6 replies, 2 voices, and was last updated 9 months, 1 week ago by
Participant.
-
AuthorPosts
-
-
April 21, 2020 at 8:26 am #220989PowerShell123456789101112131415161718192021222324252627###Windows powershell RightScript to install Espera##stop and fail script if the software alreday installed##if (${env:programfiles(x86)}){ $advatel_path = join-path "${env:programfiles(x86)}" "Advatel" }if (test-path $advatel_path){Write-Output "Espera already installed. Skipping script"read-host “Press ENTER to exit...”exit 0}if (${env:programfiles}){ $advatel_path = join-path "${env:programfiles}" "Advatel" }if (test-path $advatel_path){Write-Output "Espera already installed. Skipping script"read-host “Press ENTER to exit...”exit 0}##Prompt for admin credentials before starting##Write-Host "Please wait... "$CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())if (($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) -eq $false){$ArgumentList = "-noprofile -noexit -file [crayon-601133992c8d9464990395 inline="true" ]"{0}
-
April 21, 2020 at 8:29 am #220992
LINE 48 is where i am having issues with copying from the unc path to destination. I think the issue is the destination part.
-
April 21, 2020 at 8:36 am #220998PowerShell1"${env:programfiles(x86)}\Advatel\Espera Client\bin"
-
April 21, 2020 at 8:51 am #221010
I have tried that with no luck 🙁
-
April 21, 2020 at 9:00 am #221016
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. 😉
-
April 21, 2020 at 9:41 am #221031
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.CopyItemCommandCopy-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 -
April 21, 2020 at 9:48 am #221040
Yeah it looks like permissions
So your issue is not your Powershell code it is your lack of rights to the target folder. 😉
-
-
AuthorPosts
- The topic ‘Unable to Copy item from UNC path to destination using $en:programfiles \ (86)’ is closed to new replies.