An Introduction to the Workspace ONE MacOS Hub CLI

An Introduction to the Workspace ONE MacOS Hub CLI

apple, scripting, tools
Introduction to the Workspace ONE

Admittedly, we sometimes miss little features that vendors sneak into a random release. One of the ones that I missed is the new MacOS Hub CLI for Workspace ONE, which to be fair hasn’t been covered all that much so I wanted to bring people up to speed on the excitement of this great new feature. This really pairs nicely with my recent article getting new MacOS admins ready to support these gorgeous machines in their enterprise. Sadly, it is MacOS only but we will discuss that more later! Let’s cover the capabilities of the CLI, how you can leverage it, and some samples/demos.

Workspace ONE MacOS Hub CLI Capabilities

The MacOS Hub CLI can be found at: /usr/local/bin/hubcli

The CLI is broken into a few different commands:

  • Config
  • Notify
  • Sync
  • Logs
  • Profiles
  • Sensors

We will cover these areas and what they are/how they can be used. The main takeaway as a reminder is it requires sudo, which lends itself well to being run via Product Provisioning/Scripts which we will cover later.

Hub CLI Config

The Hub CLI Config is pretty basic. You can use Config to get/set Intelligent Hub Settings values. These settings will override the settings pushed down via UEM. We have various settings we can work with, which they refer to as “flags”:

  • All (Lists all of the settings and their values)
  • AWCM-URL (Lists the AWCM endpoint)
  • Checkin-Interval (Specifies what the Hub sync interval is between 60m and 1440m)
  • Menubar-Icon (Enables or Disables the Hub menu bar icon)
  • Sample-Interval (Specifies how often the Hub collects device info between 60m and 1440m)
  • Server-URL (Lists the UEM server endpoint)
  • Transmit-Interval (Specifies how often the Hub sends device info to WS1 UEM)

An example command would be:

Hub CLI Notify

The Notify command is a bit more interesting. You can use Notify to create a custom notification similar to how you do in hub services. Notify creaters a custom persistent native Cocoa notification that displays in the Notification Center.

The thing that really stands out with Notify is the ability to create a notification that will open an application like Safari.

The flags available for Notify are:

  • -t (Title of the notification)
  • -s (Subtitle of the notification)
  • -i (Informative text for the notification)
  • -a (The action button, which is an action it takes)
  • -b (The bash script you want to use)
  • -c (Removes the cancel button when you invoke an action button).

Some example code below:

sudo /usr/local/bin/hubcli notify -t "Mobile Jon Rocks!" -actionbtn "Come Find Out!" --script "open -a Safari"

The end result is:

This can be pretty neat actually. One of the way you could use this is to run a bash script that does something e.g. a script that I wrote that removes and reinstalls the hub.

Hub CLI Sync

Hub CLI Sync is probably one of the most useful ones. It’s a fairly basic command. You can use it to do a device sync or just target apps with the –apps flag. This is something that I think has some great utility and potential.

Hub CLI Logs

The logs command is used to collect logs and send them to a local archive or direct to the console. It’s pretty simple overall. An example piece of code can be seen below:

sudo /usr/local/bin/hubcli logs --collect --duration 1h --archive /usr/local

Hub CLI Profiles

The Profiles command is an interesting one, but I’m not sure how useful it will be. You can basically use it to list all of the profiles installed on your device.

From there, you can use the Profile IDs to reinstall a profile:

Personally, it would have been more useful to use it to remove a profile for testing, but I suppose its somewhat helpful if the device has communication issues.

Hub CLI Sensors

MacOS Sensors are new in Workspace ONE, but the CLI is doing some nice stuff with them to our advantage. You can use the CLI to list the sensors on your machine and even trigger them if needed. Overall its a nice feature to have:

Using the MacOS Hub CLI

So we have covered the aspects of the MacOS Hub CLI. Let’s cover a few nice potential use cases that I came up with.

Force All MacOS Devices to Sync

The first one is a bash script you can push down via Scripts or Product Provisioning if you want to force all of your Macs to sync after deploying something new down:

/usr/local/bin/hubcli sync 

By deploying this script, you can do a force reprocess and make all of your Macs synchronize.

Rebuild Intelligent Hub via Notification

You can download my Hub rebuild script in my Github and deploy the script below to leverage your product provisioning to potentially let people self-service reinstall the Intelligent Hub.

/usr/local/bin/hubcli notify -t "Intelligent Hub Health Check" -s "Are you getting your apps and configurations timely? Press Reinstall to refresh your services." -a "Reinstall" -b "sh /usr/local/"

A Short Demo with the Workspace ONE Hub CLI

Now after all of these lovely things, let’s take a look at a short demo of the MacOS Hub CLI in action:

Some Final Thoughts

So after spending some time working on the nice little Workspace ONE Hub CLI for MacOS, I have one true thought….. WHY IN THE HELL ISN’T THIS AVAILABLE ON PC? It’s remarkable to me when you create something this awesome and don’t build it for Windows 10 as well. VMware is really missing the boat on that one considering we cannot force device sync for Windows 10 remotely from the console and have to do some nonsense just to make it work properly.

My hope is that they will address this in the near future as it would be a huge step up on their Windows Management story, but sometimes their decisions even mystify me. Platform parity is a Microsoft problem and it should NOT be a VMware problem as a virtualization company that has done some magical things on MacOS in the last few years. Let’s keep our fingers crossed because the Hub CLI has some big time potential.



Social Media

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about the latest posts and updates.