Tag: bash

  • Scripting changing user icons: dsimport prompts for password in zsh

    2 June, 2021 Update Special shoutout to Armin Briegel for pointing out that the zsh version runs just fine if you use a different variable name from USERNAME. I’ve tried it with USERACCOUNT instead, and I’ve confirmed it works fine with zsh. Original Post Apple is moving toward making zsh the default shell instead of…

  • Running commands as a user when scripting for Munki or Jamf

    Munki and Jamf run as root, so scripts they execute execute as root, not user. One great way around this is to use Outset‘s login scripts (login-once, login-every), but sometimes you may have occasion to actually run a script immediately as the logged-in user. Obviously, you’ll want to get the currently logged-in user into a…

  • Extracting Adobe CC icons for Munki

    Generally, Munki has no problems extracting icons from .app or .pkg items it imports. Adobe makes its installers a bit annoying to get icons out of, so when you import an Adobe CC item into Munki and try to get the icon out, you’ll get this instead: Attempt to create a product icon? [y/n] y…

  • Terminal command to get the full name of a Mac user

    Munki-Enroll is a great little script combo that automatically changes the ClientIdentifier for Munki clients and then automatically creates a corresponding manifest on the Munki server that includes the old manifest. I wanted to tweak it quite a bit to fit some of the quirks of how our organization does Munki client manifests, so I…

  • Putting Dockutil add/removes in arrays in Bash

    Most of the time when you see scripts using Dockutil to add and/or remove items from the Dock in Mac OS X, they look like this: /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP1.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP2.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP3.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP4.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP5.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP6.app’ –no-restart /usr/local/bin/dockutil –add ‘/Applications/NAMEOFAPP7.app’ –no-restart That’s…

  • Filling out a Google Form from the terminal using the curl command

    Cheating a bit here by just linking to someone else’s blog post, but it’s very well written, with screenshots and different colors. Why reinvent the wheel? Here it is: Submit Google Forms By Curl Command

  • Renaming a Mac hard drive from the command line

    You know, if your hard drives are set to show as icons on the desktop, you can rename them by selecting them, hitting Enter, and then typing in a new name? If you want to script naming, you can also name from the command line. For example, if you want to rename the drive you’re…

  • Terminal command to change a user password on a Mac

    Update May, 2019 Now that there are SecureToken users, the command below no longer works to reset another user’s password. Thanks to mario on the MacAdmins Slack for testing. Acknowledgements Just a cleaned-up version of directions from Mac Script to change Administrator password Changing a user password via terminal command If you ever want to—perhaps…

  • Running a post-uninstall script for a Munki package

    Much as I love editing text files and entering commands into Terminal.app, I do also appreciate a good GUI frontend. Apart from munkiimport, I mainly manage Munki using MunkiAdmin, as I referenced in Absolute beginner’s guide to setting up Munki (not monkey). Of course, I got a bit too comfortable with the GUI frontend, and…

  • Running sudo commands in Automator

    If you’re wondering how to run sudo (for privilege escalation) commands in Automator, this is one way to do it. Launch up Automator (of course). Find Run AppleScript in the library of actions. Then, drag it over to the workflow area on the right. By default, Automator will put in some script structure for you…

  • Fix ownership of copied folders for Active Directory Macs

    Warning This script does some serious system modifications. If you don’t know what you’re doing, ask questions in the comments. Don’t just run this script if you don’t understand what it does or how it’s doing it. This also assumes short usernames match up with user folder names, which they usually do. What issue this…