Forked from justinpawela/DisableGuestAccount.applescript
Created
July 7, 2020 20:08
-
-
Save ascdso2020/c110ae556c0249649de3754ce08c1670 to your computer and use it in GitHub Desktop.
Disable macOS Guest user account script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/osascript | |
| -- License: https://justinpawela.github.io/default-gist-license/ | |
| (* | |
| 1) Disables signing in as Guest from the login screen. | |
| 2) Disables Guest access to file shares over AFP. | |
| 3) Disables Guest access to file shares over SMB. | |
| Commands are chained together so that the user only needs to authorize once. | |
| *) | |
| set shellCommands to ¬ | |
| "sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool NO; " & ¬ | |
| "sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO; " & ¬ | |
| "sudo /usr/bin/defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO" | |
| try | |
| -- Run the shell commands, after requesting user authorization. | |
| do shell script shellCommands ¬ | |
| with prompt "Attempting to disable the Guest user account." ¬ | |
| with administrator privileges | |
| on error number -128 | |
| -- User cancelled. No further action required. | |
| end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment