This method required the bluetooth menu bar status icon to show and used AppleScript GUI scripting (requires System Preferences » Universal Access » Support for assistive devices IIRC):
tell application "System Events"
tell process "SystemUIServer"
tell (menu bar item 1 of menu bar 1 whose description is "bluetooth")
click
click menu 1's second menu item
end tell
end tell
end tell
Call from command line using osascript
:
osascript -e 'tell application "System Events" to tell process "SystemUIServer" to tell (menu bar item 1 of menu bar 1 whose description is "bluetooth") to {click, click (menu item 2 of menu 1)}'
Do not edit this post. I don't care if you don't like the scroll bar. It's easier to select by triple-clicking this way.
Alternatively, you can launch System Preferences and click the checkbox:
tell application "System Preferences"
set current pane to pane id "com.apple.preferences.bluetooth"
tell application "System Events"
tell process "System Preferences"
click checkbox "On" of window "Bluetooth"
end tell
end tell
quit
end tell
While a GUI process launches, it isn't visible except for the Dock icon.