Category filter
Script to Enable Password for screen lock on Mac
Strong passwords ensure protection against unauthorized access to your macOS devices. Administrators can remotely set the Mac to require a password when it wakes from sleep with the help of scripts in Hexnode. Enabling a password will keep the data on the Mac secure when users are away from it. Hexnode helps admins perform this action with the help of Execute Custom Script command.
Scripting Language – Bash
File extension – .sh
Enable Password for Screen Lock
The below code uses the osascript
command to run an AppleScript line:
1 |
osascript -e 'tell application "System Events" to set require password to wake of security preferences to true' |
osascript –e
– Runs the main AppleScript command from within the Shell environment.
tell application "System Events" to set require password to wake of security preferences to true
– Use System Events to automatically enable the ‘Require password __ after sleep or screensaver begins’ checkbox under System Preferences > Security & Privacy without any prompts. If the System Preferences is kept open when the script is executed from the portal, you may have to exit and open the System Preferences again for the script to take effect.