Archive

Archive for the ‘AppleScript’ Category

Active Directory home directory lookup AppleScript now updated for 10.7.x

November 15, 2011 2 comments

A while back, I had posted an AppleScript that Peter Bukowinski and I had built to provide an easy-to-use way to look up the location of an Active Directory home folder. With the changes to the Active Directory plug-in on Mac OS X 10.7.x, the script also needed to be updated so I’m posting the updated script and code. The script should be usable on AD-bound 10.6.x and 10.7.x Macs, and Peter has added some new functionality to display the correct fileshare connection information for both Macs and Windows boxes.

Assumptions:

In order to work correctly, the script needs for the Mac to be bound to an AD domain. The AD-bound Mac also needs to be connected to the AD domain via a domain-reachable network connection or via VPN.

Using the script:

Launch the script and provide the username in the blank provided, then click OK.

The home folder’s address will then be displayed in a dialog box, with the correct fileshare information for both Windows and Mac. You’ll also be prompted to copy the home folder information to the Mac’s clipboard for pasting (if needed.) Click OK to dismiss the dialog without copying the information. Clicking any of the buttons will quit the script.

As before, it should be pretty generic but the only location I’ve tested it at is here at my workplace. If you’re planning to use it on 10.7.x AD-bound Macs, check the code as you will need to make some edits.

Click here to download the script

Click here to download the source as a PDF document

Looking up AD home directory locations from an AD-bound Mac

February 9, 2011 2 comments

One of the occasional issues I’ve run into at work is that we don’t have one central location that stores all of our AD home directories. As a result, telling someone where it is can take some digging and delay. To help speed up the process, I worked with Peter Bukowinski to build an easy-to-use AppleScript that looks this information up. It should be pretty generic, but the only location I’ve tested it at is here at my workplace. Your milage may vary.

Assumptions: In order to work correctly, the script needs for the Mac to be bound to an AD domain. The AD-bound Mac also needs to be connected to the AD domain via a domain-reachable network connection or via VPN.

Using the script:

Launch the script and provide the username in the blank provided, then click OK.

The home folder will then be displayed in a dialog box. You’ll also be prompted to copy the home folder information to the Mac’s clipboard for pasting (if needed.) Click OK to dismiss the dialog without copying the information. Clicking either button will quit the script.

Update: Peter added some more functionality to the script by making the copying of the information to the clipboard optional and adding error checking for when an AD account was set up without having a home directory set in the account profile. Downloads and source code have been updated to reflect the changes.

Click here to download the script. Source code is beneath the jump.

Read more…

Rebooting an Airport Extreme via AppleScript.

November 29, 2008 5 comments

After the latest firmware update for my saucer-shaped Airport Extreme base station, I’ve found myself rebooting my Airport on a much more regular basis than I had before. Before the update, I was rebooting it once in a blue moon. Now, I’m rebooting it once every couple of days. The routine goes something like this:

*Get home*
*Wife fires up her laptop*
“Honey, the internet’s broken.”
*I trudge down to my basement office and power-cycle the base station*
*Walk back up*
“Is it working now?”
“Yup.”

This got old fast, so I started thinking about ways to reboot my Airport base station nightly, preferably without human involvement. A quick Google showed surprisingly few people trying to accomplish this, but the nice folks who had also posted their AppleScripts. I’m hardly an AppleScript master, but I was able to pull together the following script using this entry from MacOSXHints, as well as this one from David Chan.

———–

tell application "AirPort Utility" to activate
delay 2
tell application "System Events"
	tell application process "AirPort Utility"
		
		tell window 1
			click button "Manual Setup"
			delay 60
		end tell
		
		tell menu bar 1
			click menu bar item "Base Station"
			
			tell menu bar item "Base Station"
				tell menu 1
					click menu item "Restart…"
				end tell
			end tell
		end tell
		
		delay 1 --imperative
		
		delay 30
		
	end tell
end tell

tell application "AirPort Utility" to quit

———–

I later added the ability to log to a file in ~/Library/Logs by using this additional script from MacOSXHints, so my current script looks like this:

———–

set commonScript to load script alias ¬
	((path to library folder from user domain as string) ¬
		& "Scripts:Common code.scpt")

tell application "AirPort Utility" to activate
delay 2
tell application "System Events"
	tell application process "AirPort Utility"
		
		tell window 1
			click button "Manual Setup"
			delay 60
		end tell
		
		tell menu bar 1
			click menu bar item "Base Station"
			
			tell menu bar item "Base Station"
				tell menu 1
					click menu item "Restart…"
				end tell
			end tell
		end tell
		
		delay 1 --imperative
		
		delay 30
		
	end tell
end tell

tell application "AirPort Utility" to quit

log_event("Basement Airport Extreme restarted") of commonScript

———–
The last piece of the puzzle was figuring out how to trigger it, but iCal came to the rescue. Maria Langer posted a good write-up on how to do this up on her site, which I was able to use to help me set up a recurring appointment at 12:00 AM every day to reboot the Airport, with the alarm for the event triggering the script that actually reboots the Airport.

restart_airport

Categories: AppleScript, Geeky, Mac OS X
Follow

Get every new post delivered to your Inbox.

Join 73 other followers