0

We are using the following software:

  • PowerShell v1
  • Windows 7 Professional

When I run the following on a remote computer in PowerShell all works correctly:
(the files from the shared folder are shown)

Get-ChildItem "\\<NAME OF COMPUTER WHICH HOSTS THE NETWORK SHARE>\ourNetworkShare"

But when I run the following from my local computer:

Invoke-Command -ComputerName <REMOTE COMPUTERNAME> 
-ScriptBlock { 
    Get-ChildItem '\\<NAME OF COMPUTER WHICH HOSTS THE NETWORK SHARE>\ourNetworkShare' 
}
-credential $myCredential

I get the following error:

Cannot find path '\\<NAME OF COMPUTER WHICH HOSTS THE NETWORK SHARE>\ourNetworkShare' 
because it does not exist. + CategoryInfo: ObjectNotFound: 
(\\<NAME OF COMPUTER WHICH HOSTS THE NETWORK SHARE>....ourNetworkShare:String) 
[Get-ChildItem], ItemNotFound Exception + FullyQualifiedErrorId : PathNotFound,
Microsoft.PowerShell.Commands.GetChildItemCommand

How can I resolve this issue?

  • Does it work from the cmd prompt with the dir command? – Greg Askew Jul 19 '17 at 14:23
  • No, as a surprise to me, it doesn't work. If i run cd \\server-name\ourNetworkShare on the remote computer in cmd following error comes: CMD does not support UNC paths as current directories – it-freelancer-magazin.de Jul 19 '17 at 14:55
  • Is the \\Server\share in the scriptblock literal or from a local variable? Has the used credential access rights on the remote \\Server\share ? – LotPings Jul 19 '17 at 15:03
  • Use pushd \\server-name\ourNetworkShare instead of cd \\server-name\ourNetworkShare in cmd. Try (. net.exe view server-name) | Where-Object { $_ -match "^ourNetworkShare" } as the scriptblock body. – JosefZ Jul 19 '17 at 15:09
  • Who said anything about cd? DIR \\SERVERNAME\SHARENAME – Greg Askew Jul 19 '17 at 15:13
1

This sounds very much like a classic Kerberos delegate/double hop issue. It can't enumerate the path because it can't delegate your credentials, so that's what I'd check first. Try using the same method to connect to just the root of the computer - I'd expect you to get a credential error, but I don't recall the exact quirks of Powershell v1 and double hop credential delegation.

If you're able to resolve this problem by enabling CredSSP for second hop, you might consider making a GPO for that, and you can find instructions on how to do so here.

On a related note, PowerShell 1 is ancient and shouldn't be used any more. Download an updated WMF and start using a more modern version of PowerShell.

  • This answer sounds plausible. Because I have no access to things like GPO or similar in this intranet, I have to stop my initiative now. Originally I thought my problem is solvable with better PS commands. Probably it isn't and I know that now. Thanks a lot! – it-freelancer-magazin.de Jul 20 '17 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.