# Invoke-command issue

**URL:** <https://forums.powershell.org/t/invoke-command-issue/17601>\
**Category:** PowerShell Help\
**Created:** [September 22, 2021, 8:27pm UTC](https://forums.powershell.org/t/invoke-command-issue/17601 "2021-09-22T20:27:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaetan321](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@Gaetan321](https://forums.powershell.org/u/Gaetan321)\
**Post date:** [September 22, 2021, 8:27pm UTC](https://forums.powershell.org/t/invoke-command-issue/17601/1 "2021-09-22T20:27:42Z")

</div>

Hello.

I’m trying to invoke-command a script on a remote system using my domain admin cred but it fails to progress

$cred=get-credential  
$comp=read-host “hostname”  
icm -cn $comp -cred $cred -FilePath \company\global\software\Allowed\_Apps\oracle\database\19c\Oracle\_prep\_install.ps1

\company\global\software\Allowed\_Apps\oracle\database\19c\Oracle\_prep\_install.ps1 looks like below

#CREATE THE ORACLE DIRECTORY  
Write-host “Creating Oracle directory” -foreground Green  
New-Item -Path C:\Oracle -ItemType directory

#Copy files  
Write-host “Copying Oracle files” -foreground Green  
copy-item -verbose -Recurse \company\global\software\Allowed\_Apps\oracle\database\19c\*.\* C:\oracle

#Unzip Oracle archive  
Write-host “Extracting Oracle Install files” -foreground Green  
Expand-Archive C:\Oracle\WINDOWS.X64\_193000\_db\_home.zip -DestinationPath C:\Oracle

The script will create the C:\Oracle dir but systematically fails to copy the files if run via invoke-command with no errors. However, it will proceed if I import a pssession with the exact same admin credentials and call the Oracle\_prep\_install script.

What am I doing wrong ?

Thanks  
G

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [September 22, 2021, 8:45pm UTC](https://forums.powershell.org/t/invoke-command-issue/17601/2 "2021-09-22T20:45:16Z")

</div>

Gaetan,  
Welcome to the forum. 👋🏽

If you are remoting to another computer you cannot remote from there to a third computer by default. That’s known as double hop problem.

To avoid this you could instead transfer the needed files to the target computer in advance and access them “_locally_” when you run your script.

BTW: When you post code please format it as code using the _preformatted text_ button ( **\</\>** ). Place the cursor on an empty line, click the button and paste your code. Otherwise the forum software will try to “interpret” your code as HTML or MarkUp tags and remove some charachters. 😉  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Gaetan321](https://avatars.discourse-cdn.com/v4/letter/g/b2d939/32.png) [@Gaetan321](https://forums.powershell.org/u/Gaetan321)\
**Post date:** [September 23, 2021, 7:53am UTC](https://forums.powershell.org/t/invoke-command-issue/17601/3 "2021-09-23T07:53:52Z")

</div>

Thank you Olaf and I will post code as advised in the future

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:21pm UTC](https://forums.powershell.org/t/invoke-command-issue/17601/4 "2024-05-16T20:21:20Z")

</div>

Closed on May 16, 2024, 8:21pm UTC


