Tag Archives: ruby gems

A practical example of using the ARD ruby gem

Here’s a practical example of using the ARD ruby gem to help organize your Apple Remote Desktop Commands.

Let’s say you already have one saved command, named “command1”.

ard-gem-01.png

existing saved command

But you want to move “command1” into a folder named “Folder1”.


Create a new folder

Let’s create the folder by using the ARD gem, with this command:

#usage
ARD.create_empty_folder("Name of new folder")

ard-gem-04.png

ard-gem-02.png

the results of running the above command


Move a command into a folder

Now lets move “command1” inside “Folder1” with this command:

 #usage
 ARD.move_command("Name of command to move", "Name of folder to move to")
 

ard-gem-05.png

ard-gem-03.png

results of running the above command

“command1” is now inside the folder. You can run this command as many times as you want just replacing the name of the command, until you have everything you want moved into a specific folder. For example .. a folder named “Printer Commands” that has four commands that help you administrate printers.

Best practice is to make sure Apple Remote Desktop is closed while running the commands, then open afterwards to see results. If the “Send Unix Command” window is open in Apple Remote Desktop, you may receive an error while running the command.

ARD gem on Github or Ruby Gems

Disable System Preference Panes In macOS

Occasionally I have a need to disable a System Preference pane on a machine. For example for a lab machine or public shared machine. You can accomplish this by using a configuration profile, which I’ve used in the past. Often times it was originally created by someone else, which means I can’t really edit it or make changes on the fly.

So I wrote Panes. A small Ruby Gem that helps me disable system preference panes. The intent is to run the commands as a postinstall script … either on the end of a DeployStudio workflow or in a payload free package.

Here’s how it works.

Install panes:

 sudo gem install panes 

verify panes installed:

 gem list 

Panes Usage

You must require panes in your ruby script, before you call it.

 require 'panes' 

To list the available system preference panes (though not all maybe available for your hardware):

 puts Panes.List 

That should display a list like this:

Accounts.prefPane
Appearance.prefPane
AppStore.prefPane
Bluetooth.prefPane
DateAndTime.prefPane
DesktopScreenEffectsPref.prefPane
DigiHubDiscs.prefPane
Displays.prefPane
Dock.prefPane
EnergySaver.prefPane
Expose.prefPane
Extensions.prefPane
FibreChannel.prefPane
iCloudPref.prefPane ......

Panes disables preferences by using the CFBundleIdentifier. To list the available CFBundleIdentifier’s:

 puts Panes.CFBundleIdentifier 

Output will look like this:

com.apple.preferences.users
com.apple.preference.general
com.apple.preferences.appstore
com.apple.preferences.Bluetooth
com.apple.preference.datetime
com.apple.preference.desktopscreeneffect
com.apple.preference.digihub.discs
com.apple.preference.displays ....

Once you have the CFBundleIdentifier you want you can disable the pane. Let’s disable the Sharing pane. Here’s the before.

Enabled.png

To disable “Sharing”:

 Panes.Disable("com.apple.preferences.sharing") 

After:

onedisabled.png

To disable multiple panes at once:

Panes.Disable(
 "com.apple.preference.dock",
 "com.apple.preference.energysaver",
 "com.apple.preference.network")

results:

disabled.png

What if you decide later that you need to enable a pane?

To enable one pane:

 Panes.Enable("com.apple.preference.network") 

or to rest and enable all panes:

 Panes.Reset 

Everything goes back to normal.

Enabled.png

For more documentation check out my GitHub or Ruby Gems.