Disable Printer Sharing on macOS using Intune Policy

A guide to turn off the printer sharing on Mac devices using Microsoft Intune

Prajwal Desai
Posted by Prajwal Desai
Disable Printer Sharing on Mac using Intune

In this post, I will show you how to disable printer sharing on macOS using Intune policy. Using a DisablePrinterSharing.zsh shell script, you can turn off the macOS printer sharing feature via Microsoft Intune.

When you enable printer sharing on a Mac, it is set up as a print server to accept print jobs from other computers. Apple recommends using a dedicated print server or direct IP printing instead of printer sharing.

An organization recently approached me about stopping Mac users from enabling and using the printer sharing feature. Thankfully, the Mac devices in the enterprise were enrolled in Intune. However, they couldn’t locate a setting to turn off printer sharing for Mac in the settings catalog.

When I did some research, I discovered that there is no option to disable printer sharing for Mac devices in the settings catalog. So, I had to either use a script or a custom template to get this done. Thankfully, Microsoft provides a DisablePrinterSharing.zsh shell script to disable printer sharing, which I used and it worked.

Prerequisites

Ensure that the following prerequisites are met when composing shell scripts and assigning them to macOS devices:

  • Devices should be running macOS 12.0 or later.
  • macOS devices must be enrolled and managed by Intune.
  • The Mac devices are connected directly to the Internet. Connection through a proxy is not supported.
  • Shell scripts begin with #! and must be in a valid location, such as #!/bin/sh or #!/usr/bin/env zsh.
  • Command-line interpreters for the applicable shells are installed.

For deploying shell scripts using Intune, refer to my guide on how to run shell scripts on macOS devices in Intune.

Download DisablePrinterSharing.zsh Shell Script

Microsoft provides a shell script called ‘DisablePrinterSharing.zsh‘ that disables printer sharing on Mac devices. Download the latest version of this script from the Intune GitHub repository.

Note: If you are an organization, I don’t recommend deploying this script to your Mac devices without proper testing. You should test the script’s execution on a small number of devices (pilot devices) and then scale up the deployment to a larger number of devices.

Disable Printer Sharing on macOS using Intune Policy

Follow the below steps to upload the DisablePrinterSharing.zsh shell script to Intune and create a policy that will disable printer sharing on macOS devices.

  • Sign in to Microsoft Intune Admin Center.
  • Navigate to Devices > macOS and select Shell Scripts.
  • Click the Add button to upload the DisablePrinterSharing.zsh script for macOS.
Disable Printer Sharing on macOS using Intune Policy
Disable Printer Sharing on macOS using Intune Policy

Enter a name for the profile in the Basics tab of the Add Script pane. Add a brief description about the policy.

For instance, you can enter the following information for the Shell script:

  • Name: Turn off printer sharing on Mac
  • Description: Disable printing on a macOS that is managed by Intune

Click Next.

Disable Printer Sharing on macOS using Intune Policy
Disable Printer Sharing on macOS using Intune Policy

On the Script Settings tab, upload the shell script. Click on the Browse icon and select the DisablePrinterSharing.zsh script.

If you’re using a custom script, keep in mind that the macOS shell script file that you upload must be less than 200 KB in size. You can view the script that has been uploaded, but you cannot edit or modify the script at this time.

upload the DisablePrinterSharing.zsh shell script to Intune
Upload the DisablePrinterSharing.zsh shell script to Intune

Scroll down to configure the following script execution settings:

  • Run script as signed-in user: No
  • Hide script notifications on devices: Yes
  • Script frequency: Every 1 week
  • Number of times to retry if script fails: 3 times

Click Next.

Configure DisablePrinterSharing.zsh execution
Configure DisablePrinterSharing.zsh execution

On the Assignments tab, you select the Entra ID groups to assign the shell script. The groups you select are shown in the list and will receive your script policy. Click Next.

Disable Printer Sharing on macOS using Intune Policy
Disable Printer Sharing on macOS using Intune Policy

In the Review + Add tab, a summary of the settings you configured is shown. Select Add to save the script. When you select Add, the script policy is deployed to the macOS device/user groups you chose.

You’ll see a notification “Upload completed for Disable Printer Sharing.zsh” confirming that the script has been uploaded successfully to Intune.

Disable Printer Sharing on macOS using Intune Policy
Disable Printer Sharing on macOS using Intune Policy

The script and the policy that you created will now appear under the list of scripts. If needed, you can select and view the contents of macOS shell scripts after you upload them to Intune.

Next, you must wait for the shell script policy to apply to the targeted groups, and once the macOS devices check in with the Intune service, they will receive the script. You can also run Check Status in company portal on your Mac device to retrieve the latest policies from Intune.

Monitoring the script deployment

Now it’s time to monitor the script deployment on macOS devices and verify that the printer sharing feature is disabled on these devices.

 You can monitor the run status of all assigned macOS scripts for users and devices by choosing one of the following reports in the Intune admin center:

  • Shell Scripts > Select the script to monitor > Device status.
  • Shell Scripts > Select the script to monitor > User status.

From the screenshot below, we see the disable printer sharing script has been successfully executed on our Mac devices. This confirms that the script we assigned to disable printer sharing works properly on Mac devices, and if you follow the steps in order, you will get the same results.

Disable Printer Sharing on macOS using Intune Policy
Disable Printer Sharing on macOS using Intune Policy

Read Next

Share This Article
Prajwal Desai
Posted by Prajwal Desai
Follow:
Prajwal Desai is a Microsoft MVP in Intune and SCCM. He writes articles on SCCM, Intune, Windows 365, Windows Server, Windows 11, WordPress and other topics, with the goal of providing people with useful information.
Leave a comment