ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Automating Chocolatey with PsExec

    Scheduled Pinned Locked Moved IT Discussion
    psexecwindowschocolatey
    3 Posts 3 Posters 2.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Chocolatey, the command line driven package manager for Windows, is easily automatable making it much more enterprise ready. One of the easiest and most traditional ways to do this is via the Sysinternals’ tool PsExec which is a free tool which you can download directly from Microsoft or install using Chocolatey.

      I won’t go into using PsExec here as that is well documented online on the Sysinternals site. But using it in conjunction with Chocolatey is very straightforward. What we will do is make a basic FOR loop to handle the real work for us. Assuming all of our desktops are named “desktop%” where the % represents a numerical sequence, we could use the following one liner to do updates for us:

      FOR %i in (desktop1 desktop2 desktop3) DO PsExec.exe \%i cup all

      Obviously you simply put the list of machines on which you want to update all of your packages in a space delimited list inside of the parenthesis. Very simple.

      Now to take this to the next level, we should put our list of machines to update into a text file. This makes things much easier. Start my making a text file called host_list.txt and put a number of hostnames into it, one on each line. Once we have this we have a simple way to iterate through an arbitrary number of Windows machines with a single, one line script.

      Now we can do an update of all software on every machine like this:

      FOR /F “tokens=*” %i in (host_list.txt) DO PsExec.exe \\%i cup all
      

      Or to install new packages:

      FOR /F “tokens=*” %i in (host_list.txt) DO PsExec.exe \\%i cinst 7zip
      

      Now you have a super easy means of using command line package management from a central location.

      Originally published on 15th March 2014 on scottalanmiller.com

      https://web.archive.org/web/20150214014748/http://www.scottalanmiller.com/windows/2014/03/15/automating-chocolatey-with-psexec/

      1 Reply Last reply Reply Quote 2
      • DashrenderD
        Dashrender
        last edited by

        damn, I forgot about this post!

        A 1 Reply Last reply Reply Quote 1
        • A
          Alex Sage @Dashrender
          last edited by

          @Dashrender said:

          damn, I forgot about this post!

          Me too!

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post