0

I am having an issues with copying an item to a remote computer. I am using credentials for a domain admin to push remote installs. I am able to run this file locally however trying to push MSI file from a remote location it errors out. So i wanted to copy the file locally and run the file from there. I copied the file manually and tested my code and the msi file installs correctly however I am unable to have power shell copy the file automatically.

I have tried using quotes and escaping the spaces with no change.

Please see code below;

Function Install-MSI
{
    Write-Host "Installing MSI Files..."
    $oSession = New-PSSession -ComputerName $sComputer -Credential $oCerdentials
    $sResults = Invoke-Command -Session $oSession -ScriptBlock {    
        $Source = "\\Servername\Folder1\Folder 2\Folder3\Folder 4\File Name with Spaces (64-bit).msi"       
        Copy-Item -Path $Source -Destination C:\Users\User\Desktop\
        Start-Process MSIExec "/i `"C:\Users\User\Desktop\File Name with Spaces (64-bit).msi`" /passive /norestart /lv C:\Users\User\Desktop\log.txt"
    }
}

Error

Cannot find path '\\Servername\Folder1\Folder 2\Folder3\Folder 4\File Name with Spaces (64-bit).msi' because it does not exist.
    + CategoryInfo          : ObjectNotFound: (\\Servername...es (64-bit).msi:String) [Copy-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
  • That issue has a completely different error message. I am not having problems connecting to a remote computer and issues commands. – Cody White Apr 27 '15 at 20:33
  • The error message is different because the other issue is attempting to directly launch an executable on the UNC share, whereas you are trying to copy items. The underlying problem is the same though, you can't remote into a machine with your kerberos credentials, then pass those credentials onto a third machine. You can search for "double hop" to find more like this. This comes up a lot on this site, and there are many blog posts about it also. – briantist Apr 27 '15 at 20:36
  • Are you sure the remote computer/account used can access the UNC path? You might want to try copying the file from the initiating machine (the machine the script runs on) to the remote machine, then run it locally on the remote machine using Invoke-command. – jurgenb Apr 27 '15 at 20:39
  • Braintist - Hmm. OK I will look further into this. If this is the case which it sounds like it might be, moving the copy into the main section of my program will allow me to copy from one server to another before I remote into the computer and the files will already exist. – Cody White Apr 27 '15 at 20:41
  • n3wjack - I have already proved this and the UNC path does exist with the credentials passed to the remote computer but as Braintist states it looks like the "Double Hop" is the issue, I have more testing to be sure. – Cody White Apr 27 '15 at 20:43

0 Answers0