
If you have servicenow and chocolatey in your company this is a great project to provide your users with a way to get software without depending on a busy IT admin to remote in to your PC, download files and install apps. Chocolatey steamlines app installs and Service Now takes the same request the user would’ve submitted to a person and turns it into a powershell script that is securely executed with your mid servers. In this article we show the basics of the integration.
Requirements:
– Choco client is installed on the target
– Mid servers are configured and have network access to targets.
– IntegrationHub in ServiceNow enabled
I. Create the credential

II. Create the CI
You need to have the software to be installed and the target where the software will be installed by Choco. To restrict you can sync a group of servers or computers and only certain software. Make sure to add the FQDN if requires for powershell WinRM to use SSL and the name of the app from chocolatey’s community app package.



III. Create the Action
When creating the action make sure you create 2 inputs to pass the selection from the catalog item to the script. You can the drag and drop the values to the script’s parameters.

Add the credential you created above and link your mid server.


A simple one liner for this demo will work but you can add error checking on your own scripts. The key is to use the local variable in the remote session by utilizing the modifier named $using:$var
Invoke-Command -Credential $cred -ComputerName $mach - ScriptBlock {choco install $using:$app -y}
IV. Create the flow
You can add an approval step so that there is a human check between the request and the automated install but not required. The main steps are to get the variables from the catalog item, step 3, and then add the powershell step action we created above. Since it has the inputs we can map the variables of the CI to the parameters of the script.

V. Test and see the result
When the user submits a task and it is approved, servicenow will use the Midserver to remote in to the target machine and run the choco command. You can see the output as if you were running it on the local shell.

In this example we only show basic functionality but we recommend adding error checking and steps to create a task if the automation fails.