Axiom
Axiom

Reputation: 33

Using chocolatey and invoke-command on a remote share

I am trying to use invoke-command to install some chocolatey packages.

When the files are embedded in the chocolatey package, it works without problems. However, when I try to specify a share on a remote server and even opening it in read/write for everyone, I get an access denied when chocolatey try to access it.

Ironically, if I do the same command on the target computer and not using invoke-command, it works like a charm!

Is there something I am not getting?

The powershell script is standard:

$Computers = Get-Content -Path "C:\Users\ladmin\Desktop\testpowershell\vm3.txt"
$Cred = Get-Credential $env:USERNAME


foreach ($Computer in $Computers)
    {
        $Computer
        Invoke-Command -ComputerName $Computer -Credential $Cred -ScriptBlock {choco install ue-4.24-zip -my -t=0}
    }

And here is my chocoinstall script:

$ErrorActionPreference = 'Stop'; # stop on all errors
$fileLocation = '\\testserver\test\UE_4.24.zip'
Install-ChocolateyZipPackage $packageName $fileLocation -UnzipLocation "c:\test"

I really don't get what I am doing wrong.....

Upvotes: 1

Views: 611

Answers (1)

mwallner
mwallner

Reputation: 1075

You'll most likely be experiencing the "douple hop problem".

See

You have a couple of different ways to resolve this problem, such as setting up CredSSP, Kerberos constraint delgation, JEA, or the 'simplest' solution: just pass a PSCredentials object to the Invoke-Command script block you're using to install the Chocolatey packages and use these to setup the required network resources.

I'd suggest you look into Boxstarter for deploying Chocolatey packages to remote hosts.

Upvotes: 1

Related Questions