My slides and some example scripts from my talk, “Ruby for MacAdmins”, is posted on my Github. Thanks to everyone who helps to put the conference on, it really is top notch.
Link for Ruby for MacAdmins session.
My slides and some example scripts from my talk, “Ruby for MacAdmins”, is posted on my Github. Thanks to everyone who helps to put the conference on, it really is top notch.
Link for Ruby for MacAdmins session.
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”.
But you want to move “command1” into a folder named “Folder1”.
Let’s create the folder by using the ARD gem, with this command:
#usage ARD.create_empty_folder("Name of new 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")
“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.
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
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.
To disable “Sharing”:
Panes.Disable("com.apple.preferences.sharing")
After:
To disable multiple panes at once:
Panes.Disable( "com.apple.preference.dock", "com.apple.preference.energysaver", "com.apple.preference.network")
results:
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.
For more documentation check out my GitHub or Ruby Gems.