3

Running the following powershell command

invoke-computer -computer computer -scriptblock{remove-item -force \\otherpc\backup_dump\TEST\*}

I receive the error

An object at the specified path \otherpc\backup_dump\TEST\ does not exist.

But when I run it locally it works, I suspect there is something to do with scope here but I'm not sure of that, any help would be great.

Scott Lawrence
  • 6,993
  • 12
  • 46
  • 64
bEUY
  • 127
  • 3
  • 9

4 Answers4

3

This is the classic CredSSP issue. Check this: Mutli-Hop authentication using CredSSP

ravikanth
  • 24,922
  • 4
  • 60
  • 60
  • Your article is great, but is there a way to avoid typing a password each time you issue a remote command? (similar as ssh-agent on ssh) – static_rtti Jul 16 '13 at 11:49
  • 1
    you can create a credential object using Get-Credential and use the -Credential parameter. – ravikanth Jul 16 '13 at 14:46
0

Could you use the local path (C:\otherpc\backup_dump\TEST*) instead of the UNC path?

Scott Lawrence
  • 6,993
  • 12
  • 46
  • 64
0

Prepend filesystem:: to the UNC path.

invoke-computer -computer computer -scriptblock{remove-item -force filesystem::\\otherpc\backup_dump\TEST\*}

See http://www.powershellmagazine.com/2012/11/05/pstip-using-unc-paths-when-working-with-powershell-providers/

0

A long shot but maybe your (unquoted) path \otherpc... is interpreted as a local path? Have you tried quoting the path, like so:

... remove-item -force "\\otherpc\backup_dump..."

Emil G
  • 1,211
  • 1
  • 14
  • 26