I’m very proud of this one because I was told multiple times that it couldn’t be done by Connectwise themselves…

What are we trying to achieve?

I wanted to be able to make a single installer for Connectwise Control (hereafter called CWC) and then put the clients in their appropriate groups programmatically afterwards.
There’s several issues with this- CWC writes a non Mac-like preferences file that has the group in it, but even after I worked out how to update this properly, the client didn’t move to the correct group. This meant that once the client is installed, you have to modify the Server to set the group.

But this is an issue, because all the info that we might need to do that is on the client. In our setup- we install Mosyle first, which installs Munki and Watchman Monitoring as well as CWC. All of these installers are generic, but inside Mosyle there’s a script that changes the group for Watchman. and that has the info I needed…

OK, first you’ll need the log in to CWC, go to ‘Admin’ then ‘browse extension marketplace’ and find a CWC extension called

‘Set Session Properties From System Variables’

I know you’re disappointed right now, thinking ‘I could have done this myself!’ And honestly I wish you had, because I spent a loooong time figuring out the rest. The extension was written by Steven Dove while working for LabTech/ Connectwise but unfortunately the forum page with the instructions and discussion was down at the exact time I needed it, so I had to reconstruct it from the Wayback Machine and Imgur. Here’s the link in case it ever comes back. And here’s the Wayback link in case it doesn’t. I’ve reconstructed the whole article on my machine, I’ll post it if needed.

Now the big issue for me is the terminology used, so please excuse me if you find this boring. I wanted to do the following-

  1. Set the users ‘Full Name’ or RealName’ as the ‘Session Name’
  2. Set the Company Name based on the ‘Group Name’ already existing in Watchman monitoring on the client


In CWC there’s a field called ‘Name’. We would normally have either the username or the Server name in here. for Apple user accounts, there’s 3 variables, ‘Full Name’, ‘Short Name’ and ‘Password’. For this name field, we want the ‘Long Name’ or in the DSCL tool ‘RealName’
Because CWC issues all commands as root, we actually need to get the logged in users name first, then from that get the RealName

Get currently logged in users name-

stat -f "%Su" /dev/console

Get RealName-

dscl . -read /Users/$shortname RealName

Combine these together, declare the variable and add a pipe to remove the prepended answer text-

RealName=$((dscl . -read /Users/$(stat -f "%Su" /dev/console) RealName) | tail -n1)


To get the company name, we want to derive that from the group set in Watchman. That’s pretty simple

defaults read /Library/MonitoringClient/ClientSettings ClientGroup

Or setting the variable-

CompanyName=$(defaults read /Library/MonitoringClient/ClientSettings ClientGroup)

Putting it all together

Now we have to go back to the extension and set it up. In the extension, ‘SessionNameVariableName’ actually corresponds to ‘SessionProperty.Custom1.LabelText’ so we put our variable ‘RealName’ in there so it will overwrite the ‘Name’ field in CWC, and set it to ‘Custom’.

Next we find that ‘CustomProperty1VariableName’ in the extension actually refers to a field that I’ve set up called ‘Company’ (I think default is similar but different) so we put our variable ‘CompanyName’ in here. Looks like this-

Extension Settings



Now for the magic sauce. We’ve got 2 commands so we paste each on one line in the ‘MacPreCommand’ section, so it looks like this

MacPreCommand Setup




It’s not perfect, here are a couple of issues I’ve found
• If an account ‘Full Name’ is only one word, the text cleanup doesn’t work well and you still get ‘Realname: ‘ in the Name field
• Not so good for Servers where they will often have generic logins, so do these manually
• On reboot I had to go to the CWC Admin Panel to ‘wake up’ the extension before it would work. Not sure if this weirdness is permanent, Safari or other

I’m prepared to live with these although I think the first one could be fixed, it’s saved me a lot of time!