In this post, I will show you how to run shell scripts on macOS devices in Intune. You can use shell scripts on macOS devices to extend device management capabilities in Intune.
We all know that you can deploy PowerShell scripts on Windows devices using Intune. Running a shell script on a macOS device is a game changer since these scripts allow you to make complicated changes to your macOS devices. If you have numerous Mac devices in your setup, you may use Intune to mass distribute configuration updates to these devices.
When you create and assign a shell script policy to macOS devices, it is run as a distinct process, and the run status is provided back to Intune, enabling administrators to monitor execution success or error codes. When you set the scripts to run at regular intervals, the scripts are saved locally to save download time.
Note: Rosetta 2 is required to run the x64 (Intel) version of apps on Apple Silicon Macs. To install Rosetta 2 on Apple Silicon Macs automatically, you can deploy a shell script in Endpoint Manager. Also, see how to manage software updates on macOS using Intune.
Prerequisites
The following prerequisites are required to run shell scripts on macOS devices using Intune:
- The macOS devices must be running version 11.0 or later.
- You must enroll macOS devices in Intune before you run shell scripts.
- The macOS devices must be connected directly to the Internet. Connection through a proxy is not supported.
- You must have a script ready to apply it to macOS devices.
- Shell scripts begin with #! and must be in a valid location such as #!/bin/sh or #!/usr/bin/env sh.
- Command-line interpreters for the applicable shells are installed.
https://fofabaike.com/forum.php?mod=viewthread&tid=894
https://fofabaike.com/forum.php?mod=viewthread&tid=513
https://fofabaike.com/forum.php?mod=viewthread&tid=835
https://cartoonani.yju.ac.kr/free/18361
http://www.thesheeplespen.com/chat/viewthread.php?tid=264877
http://www.thesheeplespen.com/chat/viewthread.php?tid=187542
https://www.wolala.love/thread-43243-1-1.html
https://www.101skins.com.tw/forum.php?mod=viewthread&tid=4933057
https://www.101skins.com.tw/forum.php?mod=viewthread&tid=5029876
https://www.101skins.com.tw/forum.php?mod=viewthread&tid=4947508
http://newmoojin.co.kr/bbs/board.php?bo_table=free&wr_id=65770
http://mystrotain.free.fr/forum/showthread.php?tid=51388
Considerations for using macOS Shell Scripts with Intune
Listed below are important considerations provided by Microsoft before using shell scripts on macOS devices using Intune:
- Shell scripts require that the Microsoft Intune management agent is successfully installed on the macOS device. If you have enrolled the macOS devices into Intune, you don’t have to worry about this.
- Shell scripts deployed via Intune run in parallel on devices as separate processes.
- Shell scripts that are run as the signed-in user will run for all currently signed-in user accounts on the device at the time of the run.
- An end user is required to sign in to the device to execute scripts running as a signed-in user.
- Root user privileges are required if the script requires making changes that a standard user account cannot.
- Shell scripts will attempt to run more frequently than the chosen script frequency for certain conditions. For example, if the disk is full, if the storage location is tampered with, if the local cache is deleted, or if the Mac device restarts.
- The shell scripts that are running for longer than 60 minutes are stopped and reported as “failed“.
Get the Shell Script Ready for macOS
As mentioned earlier, you must have the shell script ready so that you can run it on your macOS devices. I will be deploying a sample macOS shell script that will enable remote management on Mac.
For beginners, Remote Management in Mac lets remote users manage the device using Apple Remote Desktop. It permits those users who have predefined access to the device to manage the system, interact with users, configure preferences, deploy files, etc. Mac users can manage (turn on/off) the remote management from the System Preferences (System Settings> General > Sharing > Remote Management).
The below script activates the remote management on your macOS devices. Open the Notepad application, copy the below code to a file, and save it with the filename.sh (An SH file is a script that can be run with the Bash Unix shell). You’ll need to upload this file to Intune in the next step.
Note: Before you create and assign a shell script policy in Intune, it must be tested for functionality. Execute it manually on a Mac device to validate the script works.
Run Shell Scripts on macOS devices in Intune
Let’s go through the steps to run shell scripts on macOS devices in Intune. Use the following steps to create and assign a shell script policy to macOS devices in Intune.
- Sign in to Microsoft Intune Admin Center.
- Navigate to Devices > macOS and select Shell Scripts.
- Click the Add button to create a Shell Script for macOS.
Enter a name for the profile in the Basics tab of the Add Script pane. Add a brief description of the policy.
For instance, you can enter the following information for the macOS Shell script:
https://www.truecrimecollectors.com/showthread.php?tid=6601
https://www.openhelbreath.com/showthread.php?tid=4487
http://forum.badcity.live/showthread.php?tid=22
https://www.63game.top/thread-4136-1-1.html
https://www.63game.top/thread-3473-1-1.html
https://www.63game.top/thread-3234-1-1.html
https://australiantravelforum.com/travel/showthread.php?tid=86325
https://tasarhoa.com/hoa/viewtopic.php?t=25945
http://www.yypf.com/showthread.php?tid=1516
Name: Enable Remote Management on macOS Devices
Description: Remote Management in Mac lets remote users manage the device with the help of Apple Remote Desktop.
Click Next.
On the Script Settings tab, you must upload the script. Click on the Browse icon and select the shell script. The macOS shell script file 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.
Scroll down a bit, and here you’ll find a few important settings that can be configured for your macOS script execution.
Run the script as a signed-in user: Select Yes to run the script with the user’s credentials on the device. Choose No (default) to run the script as the root user. By default, the script is run as the root user. The root user can make system changes that a standard user account can’t.
Hide script notifications on devices: By default, script notifications are shown for each script that is run. End users see an IT configuring your computer notification from Intune on macOS devices. When not configured, these messages are shown in Notification Center.
Script frequency: Select how often the script is to be run on macOS devices. Select Not configured (default) to run a script only once.
Max number of times to retry if the script fails: Select how many times the script should be run if it returns a non-zero exit code (zero meaning success). Select Not configured (default) to not retry when a script fails.
Comments
Post a Comment