Category filter

Turn on/off location services on Mac using scripts

Location Services enable several macOS applications and services to gather and use information based on the current location of the Mac, which in turn enhances the user experience. There are certain apps like Maps, for instance, which require the current location of the device to function effectively. This information is collected and provided by Location Services. However, by enabling Location Services the possibility for security threats such as tracking online behavior, theft of identity and lack of privacy in general increases. It is the IT admin’s discretion whether or not to enable/disable Location Services on their fleet of devices.

Location Services can be enabled/disabled for the Mac altogether and if enabled, it can be enabled/disabled for each app/service individually. In this document, we provide scripts which IT admins can use to remotely enable/disable Location Services for macOS devices using Hexnode UEM’s Execute Custom Script action.

Scripting language – Bash

File extension – .sh

Disclaimer:


The sample scripts provided below are adapted from third-party open-source sites.

How to enable Location Services on Mac?

Execute this command and restart the device to enable Location Services.

What happens at the device end?

Location services enabled at the device end under Security & Privacy preferences

On restarting the device, Location Services will be enabled. It will not affect the existing location services setting of individual applications and services.
That is, the apps/services whose checkboxes had previously been marked will be allowed access. Further changes can be made by the admin user at the device end.

How to disable Location Services on Mac?

Execute this command and restart the device to disable Location Services.

What happens at the device end?

Location services disabled at the device end under Security & Privacy preferences

On restarting the device, Location Services will be disabled. None of the apps/services will be given access to the service.

Notes:

  • The scripts given above are OS version dependent.
  • The above scripts can only enable/disable Location Services. They cannot be used to specify the apps/services that should be given access to the location services.

How to view the current status of Location Services?

Execute this command to check whether Location Services is currently enabled or not. The output can be viewed under the Action History tab of the device.

enabling location services via execute custom script action

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository