Tag Archives: Apple

Rename Computer using Scripting and Google Sheets

UPDATE: You need to allow redirects in your cURL by adding -L. See this post.

With Apple’s Device Enrollment program, when a organization-owned device first turns on, it checks in with Device Enrollment and gets the information to know what MDM is managing it and how to contact it. That MDM system can then install what’s known as a bootstrapping package.

In our old bootstrapping package, which was developed by an employee no longer here, was a giant if statement. If SerialNumber = x then set ComputerName to Bob, elseif SerialNumber = y then set ComputerName to Frank, elseif SerialNumber = z then set ComputerName to Jane. Pretty simple and straight forward, but a long list that is static and cannot be updated, without getting the package, rewriting the script to include new computers, repackage it and redeploy it. UGH!

I can’t find the original package. It’s in AirWatch, but sadly, I can’t find a “Download your package” button anywhere in there.

So I was going to rewrite it. Then I came across a page that talked about doing it from a spreadsheet. So I thought, well I can host a CSV file on a server somewhere and the computer can use the curl command to download it. Then I discovered that you can curl command to download a Google Sheet from the internet. At that point then I never have to change the package again1, I just have to update the Google Sheet.

I got into some trouble, and as usual, the killer community in the #toronto channel of the MacAdmins Slack are amazing and came to the rescue.

Specifically @Gerk, I had this weird awk command that wasn’t working. I also didn’t quite understand the command I had found in my Googling. He told me how he would do it, I quickly changed the line and tested it and it worked. I think googled how to parse $LINE variable to only have the value prior to the ,.

I think this works well. If anyone wants to improve on it, let me know. This is why we share knowledge in the MacAdmins community.


# Get the current device's serial number
SERIAL="$(ioreg -l | grep IOPlatformSerialNumber | sed -e 's/.*\"\(.*\)\"/\1/')"

# Where the file will be saved using today's date. On date of writing would be /tmp/serials20190802.csv
OUTPUT=/tmp/serials$(date +%Y%m%d).csv

# Download the CSV from Google Drive, file must be set to Shared With Anyone with Link (or Shared with Anyone)
curl 'https://docs.google.com/spreadsheets/d/YOURGOOGLESHEETIDHERE/export?exportFormat=csv' -o $OUTPUT

# With much thanks to @Gerk and the rest of the crew on the MacAdmins #toronto channel, this now grabs the entire line from the CSV file 

# This will grab all the text before the ,
ASSETTAG="$( cut -d ',' -f 1 <<< "$LINE" )"

# Set the ComputerName, HostName and LocalHostName
scutil --set ComputerName $ASSETTAG
scutil --set HostName $ASSETTAG
scutil --set LocalHostName $ASSETTAG
  1. Well, never say never []

Find a Mac’s serial number in Recovery Partition or the macOS installer

I couldn’t find this anywhere, so I thought I’d blog about this. Thanks to the #general channel on the MacAdmins Slack for the help.

To find a serial number for a Mac when booted into the Recovery Partition or the macOS installer, to go Utilities and choose Terminal, type in ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}'

That’s it, it will output the serial number for the computer.

NetGear ReadyNAS Time Machine Backup

It seems you cannot mount your Time Machine backup on a ReadyNAS device using normal credentials. Time Machine is segmented off with a special user. Which means I needed to restore my computer using Migration Assistant. It took FOREVER over wifi. However, I seem to be missing my Aperture Libraries. What’s the solution? Assuming it was backed up, I need to find the sparsebundle. It took a lot of searching, but I found it, and will share my brilliance with you in case you ever need to find it, too.


To access: SSH in as root. Then copy the files to a SMB or AFP accessible directory.

cd /data/.timemachine
cp -R * /home/<yourusername>

Apple Canadian Settings through MCX


I was tired of looking at my end-user’s screens and calling up “Managed Software Center” rather than “Managed Software Centre.” I figured I would enforce both the system-wide language setting, as well as enforce keyboard layouts to include both Canadian English and Hebrew.

Those are kept in two files.

com.apple.HIToolbox.plist holds the Keyboard settings
.GlobalPreferences.plist holds the language settings

The leading . means that it’s an invisible file, but you can use the terminal to copy it to another location:

cp ~/Library/Preferences/.GlobalPreferences.plist /PATH/TO/GlobalPreferences.plist

If you notice that in the second path, I removed the leading . to make it visible.

.Plist setup

The keyboard settings file just need to be setup on a test machine, and then copied, and it will work as is.

When I set it up with the Canadian English keyboard and Hebrew keyboard, it looks like this…

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<key>KeyboardLayout Name</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<key>KeyboardLayout Name</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<key>KeyboardLayout Name</key>
<string>Keyboard Layout</string>
<key>KeyboardLayout ID</key>
<key>KeyboardLayout Name</key>

The GlobalPreferences.plist had a lot of superfluous settings in it that could be eliminated. So I slimmed it down to as follows. As you can see, AppleLanguages is an array with many entries and it starts with “en-CA”, or Canadian English, then American English, Hebrew, and then French. The rest is superfluous.

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>

You’ll then need to rename the file to include the leading . using the cp tool in the terminal.

Convert to PKG and Deployment

For deployment, I use a wonderful open source program called Munki. You can use anything that will deploy profiles. Munki doesn’t, but it deploys pkg files.

To make this MCX file I need two programs developed by Tim Sutton, mcxToProfile and make-profile-pkg.

I’ve got those two setup on my Munki server

./PATH/TO/mcxToProfile.py –plist /PATH/TO/com.apple.HIToolbox.plist –plist/PATH/TO/.GlobalPreferences.plist -i Canada\ Settings -g Organization -o /PATH/TOCanadaSettings.mobileconfig –displayname ‘Canadian Settings’ -m Once

What this is doing is calling to the python script mcxToProfile, telling it to pick up the two plists com.HIToolbox.plist and .GlobalPrefernces.plist, telling it to identify as “Canada Settings” with the organization name “Organization.” Then it uses -o to know where to spit the mobileconfig file to, including a display name and how to be managed. I want my end users to be able to customize it after first use, so we use the Once flag.

This output my .mobileconfig file. So I could quickly double-click on it and it works! However, that’s not going to help me deploy it to 200+ computers. So I need to get it into Munki, first it needs to be a PKG.

./PATH/TO/make_profile_pkg.py -m /PATH/TO/CanadaSettings.mobileconfig

This python script is pretty straightforward. You call it, tell it that you want it to dump into your Munki repo (-m) and then tell it the path to your mobileconfig file. A few seconds later, it’s in your repo and a duplicate PKG is in the directory that your mobileconfig is sitting at.

Now all you need to do is throw it into the appropriate testing manifest, make sure it works, and then slowly roll it out to your fleet.

Mac Pro eSATA

I recently purchased the 2012 Mac Pro. Not the brand-spankin-new Mac Pro that looks like a subwoofer. The giant Mac Pro which does a poor job at replacing the XServe.

I needed eSATA, but sadly the Mac Pro doesn’t have either an eSATA port, or a Thunderbolt port. I could use PCI and get an eSATA card, but that’s pricey. Instead I found NewerTech makes an eSATA extender cable. Basically it takes a spare eSATA port on the board, and makes it external, and it’s only $25. Not bad. The instructions are incredible. It gives you the choice. Pre-2008 Mac Pro, or the 2008 Mac Pro… umm, I have the 2012 Mac Pro. The website even says “Works with all Mac Pros versions*” There’s that lovely asterisk, which says…

*The 2009 Mac Pro comes equipped with two SATA ports, but one port is utilized by the factory installed optical drive connector. As a result, one of the Newer Technology eSATA Extender Cable connectors must be removed prior to installation.

*The 2010 Mac Pro comes equipped with two SATA ports, but one port is utilized by the factory installed optical drive connector. As a result, one of the Newer Technology eSATA Extender Cable connectors must be removed prior to installation.

I can live with that. I have the 2012 model, but once again, the manual is 2008 and earlier. I go to install it and the instructions make no sense. I then download a newer set of instructions which breaks installation into two versions 667MHz boards, and 800MHz boards. The 800 doesn’t make much sense for my machine. Ugh. I don’t even recall what the board speed is. I figured out that the board doesn’t have any spare SATA connectors. There’s the four drives, all are in use, and the two optical drive bays. I’m using the top drive bay for the Superdrive, but I have a free one. I only need one eSATA port anyway, so who cares. Let’s use the bottom bay. I run the cable and it’s too short. I made a quick call to my cable supplier, and they don’t carry or make SATA extension cables. It took me a few minutes to figure out this hack.

Unscrew the extension cable from the faceplate, and run the external cable internally. Not so elegant as you can see, but it’ll do. With this solution my eSATA RAID will be able to work.


The biggest pain in the ass of this whole ordeal was unplugging the lower bay from the logic board and plugging in the new cable. It’s a tight space, and I have large hands. I also was hoping that my theory was right, that the lower bay was in the lower SATA port, but I might have been wrong. Turns out I was right.



Apple Wifi Menu

Apple doesn’t always like to document things. Did you know that when you option-click on the wifi menu it gives you this…

Another Day


I woke up this morning, it was around 3:30. I didn’t want to wake up that early but I did. So I put on my GSD1 hat.

I waited around until it was a reasonable time, and then I headed to the Passport Canada office in Scarborough2. After waiting way too long, they processed my paperwork, and OH YEAH! I’ll be getting a passport.

Apple Connect 2012

From there, I went up to Steeles and joined Apple Connect 2012 after the opening talk. I don’t really know what I missed, but oh well. What I do know I missed was breakfast, and after having lunch and dinner there… OH MY GOD! I was expecting shitty sandwiches and that kind of stuff like at other Apple events I’ve been to… but no, they’re pulling out all the bloody stops3!

The sessions I did go to were thus:

Apple Environmental Footprint
There was nothing else going on at that time, and my god was this a bloody boring speech. I really don’t care what Apple’s footprint is. It was long, boring, and *YAWN*.

Lion: Where is my server?
The title made me think of this. This was a discussion mostly of where to find pieces of Lion Server that aren’t preinstalled like it used to be. The vast majority of this was pointing us to the binary for MySQL or how to enable FTP on a server4. Those things weren’t that interesting, what was were the items that he had to take out of his presentation, because since the release of 10.7.0 and the release of 10.7.3, it is not easy, and builtin.

Lion Open Directory Update
Open Directory is an authentication protocol which Macs can use to authenticate to a server. It’s a decent system, has some advantages, though, honestly it would probably be more accessible to use Active Directory, but I do not. The presenter was a programmer for the OD services. Apparently the rewrote it from the ground up and she gave a very technical and detailed examination of the services. It was interesting, but barely useful.

Certificates and PKI: Concepts and Lab
This was my favourite of the talks, mostly because of Arek Dreyer.  He is very animated and he seemed to be genuinely excited about the subject. It was an excellent two hours. We had a lot of information thrown at us, both technical and practical. We had a chance to actually play with the self-signed certificates that are default to Mac OS X Server.

I missed two sessions, as they conflicted with others, including one from Mobile Iron a third party company who make a Mobile Device Management solution. Apple just released one called Apple Configurator, which I’m looking forward to playing with along with a cart of iPads. I just worry about the fact that the app seems to be thinking the iOS apps should be volume licensed, when there is no volume licensing for Canada, yet.

The other session I missed was Intro to iOS Development. I’m a terrible developer, and honestly don’t care.

After a tasty tasty dinner, I went to downstairs to the main event room where I wrote a test for certification. OS X Support Essentials 10.7 Exam was the test, and I passed! WOOO! That makes me an Apple Certified Support Professional, whatever that means. It’s a certification that will last until Mountain Lion is released in the summer. These exams were built into the cost of the event, so I took it on a whim not expecting to pass, and without having studied, but WOO HOO I passed5!

There’s many more tests I can take tomorrow, but I’ll only be able to take one more. I can go with OS X Server Essentials 10.7 Exam  which will make me an Apple Certified Technical Coordinator. That will be a much harder exam, which I could probably pass with study, but I haven’t studied whatsoever. I could at the least read the 30 page Exam Preparation Guide.

They also have exams for Final Cut Pro X and Aperture, which have very little actual worth in the real world, I use these apps nearly constantly. They have a Level One and Level Two for FCPX, and I know I wouldn’t get to level two with my knowledge, and wonder about Level One. As for Aperture, I’m sure I can pass it in my sleep. So I don’t know which I should opt for.

Bow ties are cool

In additional to all the fun I had with Passport and AC12, I also sent an email to Wickham House Brand who have a bow tie of the month club. I signed up for three months starting in February and have yet to receive my first tie. I was kinda worried, so I sent an email. I was told it should’ve arrived last week (but I didn’t say I was in Canada, and he answered from his iPhone, so he might not have looked my order up), he suggested I contact him again at the end of the week if it hasn’t arrived.

I got home from AC12 and checked my mailbox, which had been empty every day for the past two or three weeks. There was a notice from Canada Post in there. I checked the notice and saw that Shoppers was open for another 3o minutes. I headed down the street, and got a package, which was too big for a bow tie. sure it was flat, but it was about 12″ squared. I looked at the return address, and it wasn’t from the United States, it was from Halifax… WHO WOULD BE SENDING ME SOMETHING FROM HALIFAX?!?! Then I saw the name on the return address, “Mike O’Neill.”

It was Mike O’Neill’s new record! Hooray! I had figured it would come from Zunior.com owner Dave Ullrich, who lives a few blocks away from me in Toronto6.

Sad there were no bow ties, but WOO! MIKE O’NEILL.

Man I’m tired.

  1. Get *expletive deleted* Done. []
  2. Eww, Scarborough. []
  3. Food did not contain blood. []
  4. which is omitted for good reason, use SSL. []
  5. Students, don’t follow my example. []
  6. I’ve seen him in the street a few times, he never noticed me when I waved. []

Steve Jobs

Before I run to the Rivival to see Jonathan Richman, I thought I’d write down a few thoughts on the passing of Steve Jobs.

My parents purchased a Macintosh SE in the late-1980s, and it was our first Macintosh computer. I took to it pretty easily, and I remember my mother teaching me many things on the computer, including basic scripting in HyperCard, and playing in MacPaint, and MacWrite.

In 1994 I purchased MY first Macintosh computer. I had to let the rest of the family use it, though. It was a Macintosh LC 575. I upgraded from 8MHz to a speedy 33.3MHz. That 68040 processor sped through operations in no time. It was the first computer I upgraded the RAM and hard drive of, why my parents let me do that at 14 or 15, I have no idea, but man 2GB of storage in that machine!

In high school I did a co-op, and was positioned at Apple Canada’s head office. I did support for staff, I worked a bit in the tech shop, cleaning out old Macs, I did some work with data entry, but I have two very specific memories of my time at Apple.

1) I got to join when the tech team stripped down Canada’s first All-In-One G3. That machine was UGLY!

2) I got to join the staff of Apple Canada as they watched Steve Jobs redefined the computer industry by introducing the iMac. It’s incredible how that one machine changed the world. It was interesting that no one there knew what was being announced, and all were amazing, and then criticized the lack of floppy.

After my co-op ended I run the computer department at a camp, and when that ended, I later took a job doing sales at a Future Shop-esque store that no longer exists (and was owned by Future Shop). I was the Mac guy. After I got pissed at them, I took a job for a Toronto Apple Reseller. I stayed there for six years floundering, but from there I’ve since been working as the Systems Administrator and IT Manager for a private school. As the sys admin, of a large Mac network, I often get frustrated at Apple, and that extends to Steve Jobs.

Jobs was a brilliant man, and from what I hear, an ass. He revolutionized the computer industry, and by extension the world. When Steve Wozniak created the Apple computer, Jobs and he built a great company. Jobs then went on and gathered an incredible team to make the Macintosh. When he left Apple, the company floundered and struggled to stay alive. Against everyone’s expectations, they managed to stay afloat, and after purchasing NeXT, Jobs returned to the company, and made it into one of the most successful companies… not just technology companies.

That original Mac SE is sitting in my office today.

Most viewed posts of 2010

Here’s NH2F’s top 10 posts of 2010…

10) “Mayor Staypuft,” or Adam gets bitter about Toronto’s mayor, throws insults, but still puts forward good questions, to which no one cares to discuss.
9) “Fear Of Fighting,” or Adam yammering1 about the author.
8) “Vistek,” or Adam yammering about shitty customer service.
7) “How Did JFK Get My Spaghetti Video,” or Adam photographs a hottie.
6) “The End of Stillepost.ca,” or Adam has an idea to make the world a better place, but no one gives a shit.
5) “Poutine,” or I’m drunk.
4) “Apple & Canadian English,” or Adam doesn’t like that his iPhone neglects his nation.
3) “Scott Pilgrim vs. The World,” or Adam writes about a film.
2) “The Doctor Is Out,” or Adam bids adieu to the 10th Doctor.
1) “Ward 29 Debate,” or Adam visits his all-candidates debate.

  1. “Stop your yammering, and start your plannering, promposal-wise.” []

iPhone 4

I got an iPhone 4. It’s my first smart phone.

The one thing everyone’s talking about and the one thing I most noticed with the iPhone is the signal, but it’s not what you might think. My old phone was using Telus’ old CDMA network, I couldn’t make a phone call or receive a phone call with much luck in my apartment. While I don’t live in Toronto’s downtown core, I’m not far from it. At Broadview and Danforth, if you can’t get a cell phone signal, that’s just pathetic.

Now that I’m on Telus’ HSPA+ network (3G), my signal has drastically improved. You can call me if you want. I might not answer.

As far as the antenna issue that has been widely reported. Yeah, if I hold it in a certain way, I lose signal. I just don’t hold it that way, and Apple’s sending me a free case.

Here’s where I need help. What can you suggest? I don’t have many installed. Shazaam, Epicurious, Facebook, Twitter, Google Mobile, Google Earth, Remote, Urbanspoon, and VLCRemote. I don’t care about games, just applications which will make my life better. What can you suggest.

Is it weird that I really love the look and interface of the calculator? My old phone had the shittiest calculator interface, and I used it all the time. This excites me.

32GB is not enough space
I have a large music collection, I want to have all of it on my iPhone. I can’t. Instead what I’m doing is putting what’s on my 30GB iPod (which will now live in my glove box) onto the iPhone, here’s the catch. To fit all that on, I need to use the new feature “Convert higher bit rate songs to 128 Kbps AAC.” Fab, perfect, except one thing. It takes forever to convert and transfer that much data.

Syncing and communication or use
When the phone’s syncing, which I said takes a while, you cannot use the iPhone. To do so will stop the data transfer. So if a call or more likely a text message comes in, to reply to it, you have to cancel the sync. If Emily’s wondering why it took me so long to answer her questions about going to the Miller abode, that would be why.

Sync Ringtones disables Manually Manage Music
I saw that my ringtones weren’t on the phone, so I turned on sync ringtones. Bad idea. That disabled manually manage music, and so all the music I spent days transferring was removed from the phone. Last night, it synced only about 2000 songs between 2am and 9am. We’re at 2179/4195. Sigh.

Battery life seems amazing
Can’t say more, until I use it more.

Google Sync
I use Google Hosted Apps with two domains, anklewicz.com/neverhadtofight.com (they’re the same) and myemployer.ca. I did a quick search to find out how to sync all the contacts, mail, and calendars from both accounts, and followed the instructions. Unlike the BlackBerry Google Sync, which falls to the symptoms of bad UI that BlackBerrys are known for, this was easy as pie, and I didn’t have to download any Google software. I just entered my account info into Mail, and it pulled all three things, calendar, contacts, mail. Fuck yeah!

Which calendar do you want
This one has absolutely nothing to do with Apple, that I can tell. When I connect my two accounts, it grabs the main calendar on each account. However, I have numerous calendars on each account. I have my FB Events calendar, my “Rock and/or roll” calendar, all the school calendars, etc, etc. To tell it to sync the other calendars, is roundabout and silly. You have to go to Google, and then log into your domain account, and then go to settings, and do this and that and choose this and that. It works now, though.

Making ringtones is fun

The screen and UI are elegant and beautiful

It’s much thinner than my old phone which did much less

I can’t answer it like Captain Kirk

The tinny speakers are kind of shit, but at a picnic or BBQ, you can bring it out to play music without brining another device