0

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.

Oxyauna
  • 75
  • 2
  • 9

1 Answers1

1

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.

MisterSmith
  • 2,884
  • 1
  • 10
  • 13