Oxyauna
Oxyauna

Reputation: 75

"The term 'choco' is not recognized" when executing command remotely

I'm trying to use Powershell to remotely install Chocolatey and Choco packages. I was able to install Chocolatey without issue remotely using the following (my txt file contained a single server):

$ComputerList = "C:\temp\DataDogServers.txt"
$Computers = Get-Content -Path $ComputerList

Invoke-Command -ComputerName $Computers -ScriptBlock {
    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}

When I then try to execute remote choco commands, its tosses back The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. I confirmed running choco on the remote server properly works.

Upvotes: 0

Views: 10040

Answers (1)

MisterSmith
MisterSmith

Reputation: 3654

Its probably installed but not updated the PATH of your current session. Either use the fully qualified path to choco.exe, or update/reload your PATH environment variable.

Upvotes: 1

Related Questions