0

I run a simple Get-Item cmdlet to get the below result :

(Get-Item -Path \\priam\coste\ZEDMB5T-Intransit-report\* -Include DAILYREPORT_TES_MSS_20190426_*.XLS).name

enter image description here

I try the same using an invoke-command, but it does not give me anything :

invoke-command -ScriptBlock {(Get-Item -Path \\priam\coste\ZEDMB5T-Intransit-report\* -Include DAILYREPORT_TES_MSS_20190426_*.XLS).name} -computername localhost -Credential Get-Credential

There is nothing wrong with the credentials since it does work for the below command :

invoke-command -ScriptBlock {"testing"} -computername localhost -Credential Get-Credential

enter image description here

I have access to the path as well :

 Get-Acl -Path \\priam\coste\ZEDMB5T-Intransit-report | Format-List -Property *

enter image description here

I am running the powershell ISE as an administrator, as seen in the title bar : enter image description here

I am using a recent version of PS : enter image description here

What am i doing wrong here?

faizal
  • 3,497
  • 7
  • 37
  • 62
  • when i run your command [modified for my files] in a normal PoSh shell, the Invoke-Command fails with an `Access is denied.` error message. when i run it in an elevated shell [run as administrator] it works. – Lee_Dailey Apr 27 '19 at 14:57
  • @Lee_Dailey I am running as administrator as well. But it does not return anything for me. – faizal Apr 27 '19 at 14:58
  • i am lost, then. it works for me in an elevated `run as administrator` shell. note that i am NOT talking about using an admin account ... but running an elevated shell. – Lee_Dailey Apr 27 '19 at 15:07
  • @Lee_Dailey Yes, i right-click on the "Windows Powerhell ISE" app in the start menu and choose "run as administrator". Did you try with a file share on a remote system, as opposed to a local path? – faizal Apr 27 '19 at 15:12
  • 1
    i only have one system, so that is not possible. i did try it with a shared dir and got the same result as my other tests. so you may have found the differentiator. [*grin*] here's hoping someone with more experience - and a net to test on - drops by. – Lee_Dailey Apr 27 '19 at 15:16
  • Looks like standard second-hop issue. Do you have CredSSP configured for PowerShell connections? – user4003407 Apr 27 '19 at 15:34
  • @PetSerAl No, i don't. I tried "Enable-WSManCredSSP -Role "Client" ", but i get an error "The DelegateComputer parameter is mandatory when the Role parameter value is Client.". I think it's an Azure fileshare, how would a DelegateComputer apply here? – faizal Apr 27 '19 at 15:42
  • I tried Enable-WSManCredSSP with the DelegateComputer parameter, but i get an error "Enable-WSManCredSSP : This command cannot be executed because the setting cannot be enabled." Then i tried "winrm set winrm/config/client/auth @{CredSSP="true"} ". I got an "Access is denied." error. – faizal Apr 28 '19 at 11:25
  • This is the double-hop issue. See: https://stackoverflow.com/questions/17813002/unable-to-access-unc-paths-in-powershell-remote-session – Scepticalist Apr 29 '19 at 06:23
  • @Scepticalist Understood. But looks like the only solution is CredSSP and i am not able to enable it as explained in previous comments. – faizal Apr 29 '19 at 15:33

0 Answers0