I saw this as a request on a ConnectWise Facebook group that I am, and it intrigued me. The poster was looking for an integration that took an EDF value (e-mail address in this case) from ConnectWise Automate, find the matching Manage Configuration and update the contact on it all using the API. As the Author of https://github.com/gavsto/AutomateAPI I knew this was possible so thought it would be interesting to try it and see what happens.
Some pre-requisites. This script can run from anywhere, but it needs to run on a machine that has the following PowerShell Modules installed:
My Module https://github.com/gavsto/AutomateAPI (You can install this from anywhere with Install-Module AutomateAPI
Chris Tayor’s fantastic Manage Module https://github.com/christaylorcodes/ConnectWiseManageAPI (You can install this from anywhere with Install-Module ‘ConnectWiseManageAPI’
Changes to make before running:
- Updated $EDFTitle in the Editable Script Variables section to whatever your EDF is called
- Decide whether you just want to output what “would” have happened without actually updating manage in $WhatIfOnly. $true will output log of what happens only, to do the update of the configuration this should be $false.
- You will need to include all your authentication pieces to connect to the module, which is beyond the scope of this post
You will find the script at https://github.com/gavsto/Connectwise-Automate-Public-Scripts/blob/master/Update-ManageContactOnConfiguration.ps1
I hope some people find it useful.
could this be automated further by using the last-logged in user name, operating under the assumption that the machine is domain joined or azure ad joined and the username is also the username in the email address on the CWM contact? Even better would be to apply some user-affinity logic to the script to make sure the contact is properly set based on the user who primarily uses the automate device.