Jump to content
Testing123

Deploying Chocolatey

Recommended Posts

Posted (edited)

Hey everyone,

I'm pretty new to Automate, and I know a lot of you use Chocolatey in conjunction with Automate. But I'm kind of stumped as to how to deploy Chocolatey via script.

Taking, for example, the cmd.exe installer on https://chocolatey.org/install and packaging it in an Automate script, it runs and seems to install Chocolatey as it should, but fails to add the path variable which means it can't subsequently be called with its alias in future scripts.

I think this is because I'm failing to run the command under the right context.

Running as 'Shell' presumably runs as the system account, so that doesn't work.

I'd assume that 'Shell as admin' would work as this uses the site's domain admin credentials, but no joy there either.

I'm positive I'm missing something really dumb, and whatever the answer is will help with building Automate scripting in the future.

Cheers!

 

quick edit: I did search but didn't find the answer, which makes me think this is forehead-slapping levels of easy, but I just don't seem able to crack it.

edit 2: I logged onto a machine, install chocolatey under the localadmin user. Choco /? returns okay for both the regular domain user and the local admin, but trying in command prompt in Automate still doesn't work.

Additionally, installing in the same way using NinjaRMM (running script as system user) works fine - the user, scripts in Ninja, and Ninja's command prompt can also run choco /? - I really can't work out why in Automate running as Shell or Shell as admin doesn't work (neither the user or Automate's scripting/command prompt can call choco). So whatever it is, it's an Automate lesson I need to learn.

Edited by Testing123

Share this post


Link to post
Share on other sites

Run this as a shell command in your script (do not use Shell as Admin, as any "as Admin" command runs without elevated permissions if UAC is enabled).

@powershell -NoProfile -ExecutionPolicy bypass -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Other options can be using plugins built for Chocolatey,

 

Chocolatey 4 Automate or App Genie @ www.plugins4automate.com

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for replying guys.

@Joe.McCall - Thanks for that! I suspect doing this which manually adds the path may well have worked.

In the end we got Chocolatey4Automate. It's pretty flexible actually, more flexible than I thought (I was looking at the cut-down version originally). The only wish I have is that it supported location or group policies as well as client-level, as we have clients with different needs/software stacks between locations and it would be nice to manage those via group policies.

I'm kind of bamboozled as to why the regular installer didn't work - I use Chco with other RMMs and the regular installation normally works fine with those.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...