How can you disable Gatekeeper via Terminal Commands in OS X 10.8 Mountain Lion? I am looking to replicate the Security & Privacy preference pane selection to allow applications downloaded from Anywhere to run:
By having a terminal command, I can write a script to do this task remotely rather than manually going to each Mac and changing these settings with a mouse and several clicks.
sudo spctl --master-disable will turn off the Gatekeeper checks, and sudo spctl --master-enable will re-enable them (to the default setting of App Store and signed apps — it doesn't appear that setting it to App Store-only is possible).
Note that it will not throw any error if you run it without sudo permissions, but sudo is in fact required.
I don't know if spctl --master-disable is somehow different from disabling Gatekeeper from System Preferences, but spctl --status changes to assessments disabled after disabling Gatekeeper in System Preferences.