{"id":513831,"date":"2025-08-25T12:18:24","date_gmt":"2025-08-25T12:18:24","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=513831"},"modified":"2025-08-25T12:18:24","modified_gmt":"2025-08-25T12:18:24","slug":"definir-la-strategie-de-mot-de-passe-pour-les-appareils-macos-avec-un-script-shell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/definir-la-strategie-de-mot-de-passe-pour-les-appareils-macos-avec-un-script-shell\/","title":{"rendered":"Comment d\u00e9finir la politique de mot de passe pour les appareils macOS avec un script Shell"},"content":{"rendered":"<p>Les politiques de mots de passe forts sont la pierre angulaire de la s\u00e9curit\u00e9 des appareils dans les environnements d&rsquo;entreprise modernes. Pour les professionnels de l&rsquo;informatique et les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\/\">fournisseurs de services g\u00e9r\u00e9s (MSP)<\/a> qui g\u00e8rent des flottes d&rsquo;appareils <a href=\"https:\/\/www.ninjaone.com\/fr\/plateforme-de-gestion-de-terminaux\/gestion-des-terminaux-mac\/\">macOS<\/a>, il est \u00e0 la fois essentiel et difficile de s&rsquo;assurer que les politiques de mot de passe sont appliqu\u00e9es de mani\u00e8re coh\u00e9rente sur tous les terminaux. Les scripts Shell offrent un moyen optimis\u00e9 et automatisable de configurer ces politiques, en particulier lorsqu&rsquo;ils sont int\u00e9gr\u00e9s \u00e0 des plateformes RMM plus larges comme NinjaOne.<\/p>\n<p>Cet article explique <strong>comment d\u00e9finir la politique de mot de passe pour les appareils macOS avec un script shell.<\/strong> Que vous cherchiez \u00e0 appliquer des exigences de complexit\u00e9, des r\u00e8gles d&rsquo;expiration de mot de passe ou \u00e0 limiter les tentatives de connexion, ce script fournit une solution flexible et s\u00e9curis\u00e9e.<\/p>\n<h2>Contexte<\/h2>\n<p>macOS, comme d&rsquo;autres syst\u00e8mes bas\u00e9s sur Unix, offre un contr\u00f4le de bas niveau sur les politiques d&rsquo;authentification et de s\u00e9curit\u00e9 via des outils en ligne de commande tels que pwpolicy. Toutefois, ces outils ne sont pas intuitifs et une mauvaise configuration peut entra\u00eener des vuln\u00e9rabilit\u00e9s inattendues ou le blocage de l&rsquo;utilisateur.<\/p>\n<p>Le script shell en question agit comme une enveloppe pour pwpolicy, fournissant une interface plus s\u00fbre et plus conviviale pour d\u00e9finir les diff\u00e9rents param\u00e8tres de la politique de mot de passe. Il est particuli\u00e8rement utile pour les MSP qui ont besoin d&rsquo;une m\u00e9thode reproductible pour configurer des politiques de mot de passe \u00e0 grande \u00e9chelle, \u00e0 distance et de mani\u00e8re fiable.<\/p>\n<h2>Le script<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Sets the password policy for macOS devices.\r\n# By using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n# Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n# Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n# Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n# Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n# Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n# Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n# EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#\r\n# Preset Parameter: --maxLoginAttempts \"replaceMeWithANumber\"\r\n#\t\tDefine how many incorrect password attempts are allowed before the device locks.\r\n#\r\n# Preset Parameter: --loginAttemptLockTime \"replaceMeWithANumber\"\r\n#\t\tSet the lock duration (in minutes) after the maximum login attempts is reached. Max Login Attempts is required (if not previously set).\r\n#\r\n# Preset Parameter: --daysUntilPasswordExpiration \"replaceMeWithANumber\"\r\n#\t\tSpecify how many days before a password expires.\r\n#\r\n# Preset Parameter: --minimumPasswordLength \"replaceMeWithANumber\"\r\n#\t\tDefine the minimum number of characters required for a password.\r\n#\r\n# Preset Parameter: --minimumNumbersInPassword \"replaceMeWithANumber\"\r\n#\t\tSet the minimum number of numeric characters required in the password.\r\n#\r\n# Preset Parameter: --minimumLowercaseLetters \"replaceMeWithANumber\"\r\n#\t\tDefine the minimum number of lowercase letters required.\r\n#\r\n# Preset Parameter: --minimumUppercaseLetters \"replaceMeWithANumber\"\r\n#\t\tSpecify the minimum number of uppercase letters required.\r\n#\r\n# Preset Parameter: --minimumSpecialCharacters \"replaceMeWithANumber\"\r\n#\t\tSet the minimum number of special characters required.\r\n#\r\n# Preset Parameter: --passwordHistory \"replaceMeWithANumber\"\r\n#\t\tDefine how many previous passwords must be remembered before reuse.\r\n#\r\n# Preset Parameter: --resetToDefaultPolicy\r\n#\t\tReset the global password policy to the macOS default, which only requires a minimum of 4 characters.\r\n#\r\n# Preset Parameter: --help\r\n#\t\tDisplays some help text.\r\n#\r\n# Release Notes: Initial Release\r\n\r\n# Initialize variables for various password policy parameters with default values\r\n_arg_maxLoginAttempts=\r\n_arg_loginAttemptLockTime=\r\n_arg_daysUntilPasswordExpiration=\r\n_arg_minimumPasswordLength=\r\n_arg_minimumNumbersInPassword=\r\n_arg_minimumLowercaseLetters=\r\n_arg_minimumUppercaseLetters=\r\n_arg_minimumSpecialCharacters=\r\n_arg_passwordHistory=\r\n_arg_resetToDefaultPolicy=\"off\"\r\n\r\n# Function to display the help menu, outlining the usage and available parameters\r\nprint_help() {\r\n  printf '\\n\\n%s\\n\\n' 'Usage: [--maxLoginAttempts|-a &lt;arg&gt;] [--loginAttemptLockTime|-t &lt;arg&gt;] [--daysUntilPasswordExpiration|-e &lt;arg&gt;] \r\n  [--minimumPasswordLength|-l &lt;arg&gt;] [--minimumNumbersInPassword|-n &lt;arg&gt;] [--minimumLowercaseLetters|-lc &lt;arg&gt;] \r\n  [--minimumUppercaseLetters|-uc &lt;arg&gt;] [--minimumSpecialCharacters|-sc &lt;arg&gt;] [--passwordHistory|-ph &lt;arg&gt;] \r\n  [--resetToDefaultPolicy|-d &lt;arg&gt;] [--help|-h]'\r\n  printf '%s\\n' 'Preset Parameter: --maxLoginAttempts \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Define how many incorrect password attempts are allowed before the device locks.\"\r\n  printf '%s\\n' 'Preset Parameter: --loginAttemptLockTime \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Set the lock duration (in minutes) after the maximum login attempts is reached. Max Login Attempts is required (if not previously set).\"\r\n  printf '%s\\n' 'Preset Parameter: --daysUntilPasswordExpiration \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Specify how many days before a password expires.\"\r\n  printf '%s\\n' 'Preset Parameter: --minimumPasswordLength \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Define the minimum number of characters required for a password.\"\r\n  printf '%s\\n' 'Preset Parameter: --minimumNumbersInPassword \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Set the minimum number of numeric characters required in the password.\"\r\n  printf '%s\\n' 'Preset Parameter: --minimumLowercaseLetters \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Define the minimum number of lowercase letters required.\"\r\n  printf '%s\\n' 'Preset Parameter: --minimumUppercaseLetters \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Specify the minimum number of uppercase letters required.\"\r\n  printf '%s\\n' 'Preset Parameter: --minimumSpecialCharacters \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Set the minimum number of special characters required.\"\r\n  printf '%s\\n' 'Preset Parameter: --passwordHistory \"replaceMeWithANumber\"'\r\n  printf '\\t%s\\n' \"Define how many previous passwords must be remembered before reuse.\"\r\n  printf '%s\\n' 'Preset Parameter: --resetToDefaultPolicy'\r\n  printf '\\t%s\\n' \"Reset the global password policy to the macOS default, which only requires a minimum of 4 characters.\"\r\n  printf '%s\\n' 'Preset Parameter: --help'\r\n  printf '\\t%s\\n' \"Displays this help menu.\"\r\n}\r\n\r\n# Function to terminate the script with an error message and optional help display\r\ndie() {\r\n  local _ret=\"${2:-1}\"\r\n  echo \"$1\" &gt;&amp;2\r\n  test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n  exit \"${_ret}\"\r\n}\r\n\r\n# Function to parse the command line arguments and assign values to corresponding variables\r\nparse_commandline() {\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    --maxLoginAttempts | --maxloginattempts | --attempts | -a)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_maxLoginAttempts=$2\r\n      shift\r\n      ;;\r\n    --maxLoginAttempts=*)\r\n      _arg_maxLoginAttempts=\"${_key##--maxLoginAttempts=}\"\r\n      ;;\r\n    --loginAttemptLockTime | --loginattemptlocktime | --locktime | -t)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_loginAttemptLockTime=$2\r\n      shift\r\n      ;;\r\n    --loginAttemptLockTime=*)\r\n      _arg_loginAttemptLockTime=\"${_key##--loginAttemptLockTime=}\"\r\n      ;;\r\n    --daysUntilPasswordExpiration | --daysuntilpasswordexpiration | --expiration | -e)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_daysUntilPasswordExpiration=$2\r\n      shift\r\n      ;;\r\n    --daysUntilPasswordExpiration=*)\r\n      _arg_daysUntilPasswordExpiration=\"${_key##--daysUntilPasswordExpiration=}\"\r\n      ;;\r\n    --minimumPasswordLength | --minimumpasswordlength | --length | -l)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_minimumPasswordLength=$2\r\n      shift\r\n      ;;\r\n    --minimumPasswordLength=*)\r\n      _arg_minimumPasswordLength=\"${_key##--minimumPasswordLength=}\"\r\n      ;;\r\n    --minimumNumbersInPassword | --minimumnumbersinpassword | --numbers | -n)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_minimumNumbersInPassword=$2\r\n      shift\r\n      ;;\r\n    --minimumNumbersInPassword=*)\r\n      _arg_minimumNumbersInPassword=\"${_key##--minimumNumbersInPassword=}\"\r\n      ;;\r\n    --minimumLowercaseLetters | --minimumlowercaseletters | --lowercase | -lc)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_minimumLowercaseLetters=$2\r\n      shift\r\n      ;;\r\n    --minimumLowercaseLetters=*)\r\n      _arg_minimumLowercaseLetters=\"${_key##--minimumLowercaseLetters=}\"\r\n      ;;\r\n    --minimumUppercaseLetters | --minimumuppercaseletters | --uppercase | -uc)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_minimumUppercaseLetters=$2\r\n      shift\r\n      ;;\r\n    --minimumUppercaseLetters=*)\r\n      _arg_minimumUppercaseLetters=\"${_key##--minimumUppercaseLetters=}\"\r\n      ;;\r\n    --minimumSpecialCharacters | --minimumspecialcharacters | --specialcase | -sc)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_minimumSpecialCharacters=$2\r\n      shift\r\n      ;;\r\n    --minimumSpecialCharacters=*)\r\n      _arg_minimumSpecialCharacters=\"${_key##--minimumSpecialCharacters=}\"\r\n      ;;\r\n    --passwordHistory | --passwordhistory | --history | -ph)\r\n      test $# -lt 2 &amp;&amp; die \"[Error] Missing value for the optional argument '$_key'.\" 1\r\n      _arg_passwordHistory=$2\r\n      shift\r\n      ;;\r\n    --passwordHistory=*)\r\n      _arg_passwordHistory=\"${_key##--passwordHistory=}\"\r\n      ;;\r\n    --resetToDefaultPolicy | --defaultPolicy | -d)\r\n      _arg_resetToDefaultPolicy=\"on\"\r\n      ;;\r\n    --help | -h)\r\n      _PRINT_HELP=yes die\r\n      ;;\r\n    *)\r\n      _PRINT_HELP=yes die \"[Error] Got an unexpected argument '$1'\" 1\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n}\r\n\r\n# Execute command line parsing function with the passed arguments\r\nparse_commandline \"$@\"\r\n\r\n# If environment variables for the script parameters are set, override the command line argument values\r\nif [[ -n $maxLoginAttempts ]]; then\r\n  _arg_maxLoginAttempts=\"$maxLoginAttempts\"\r\nfi\r\nif [[ -n $loginAttemptLockTime ]]; then\r\n  _arg_loginAttemptLockTime=\"$loginAttemptLockTime\"\r\nfi\r\nif [[ -n $daysUntilPasswordExpiration ]]; then\r\n  _arg_daysUntilPasswordExpiration=\"$daysUntilPasswordExpiration\"\r\nfi\r\nif [[ -n $minimumPasswordLength ]]; then\r\n  _arg_minimumPasswordLength=\"$minimumPasswordLength\"\r\nfi\r\nif [[ -n $minimumNumbersInPassword ]]; then\r\n  _arg_minimumNumbersInPassword=\"$minimumNumbersInPassword\"\r\nfi\r\nif [[ -n $minimumLowercaseLetters ]]; then\r\n  _arg_minimumLowercaseLetters=\"$minimumLowercaseLetters\"\r\nfi\r\nif [[ -n $minimumUppercaseLetters ]]; then\r\n  _arg_minimumUppercaseLetters=\"$minimumUppercaseLetters\"\r\nfi\r\nif [[ -n $minimumSpecialCharacters ]]; then\r\n  _arg_minimumSpecialCharacters=\"$minimumSpecialCharacters\"\r\nfi\r\nif [[ -n $passwordHistory ]]; then\r\n  _arg_passwordHistory=\"$passwordHistory\"\r\nfi\r\nif [[ -n $resetToDefaultPolicy &amp;&amp; $resetToDefaultPolicy == \"true\" ]]; then\r\n  _arg_resetToDefaultPolicy=\"on\"\r\nfi\r\n\r\n# Check if the script is being run as root. If not, exit with an error message.\r\nif [[ $(id -u) -ne 0 ]]; then\r\n  _PRINT_HELP=no die \"[Error] This script must be run with root permissions. Try running it with sudo or as the system\/root user.\" 1\r\nfi\r\n\r\n# Ensure the user does not attempt to set both a custom policy and reset to default at the same time.\r\nif [[ ( -n \"$_arg_maxLoginAttempts\" || -n \"$_arg_loginAttemptLockTime\" || -n \"$_arg_daysUntilPasswordExpiration\" || -n \"$_arg_minimumPasswordLength\" ||\r\n  -n \"$_arg_minimumNumbersInPassword\" || -n \"$_arg_minimumLowercaseLetters\" || -n \"$_arg_minimumUppercaseLetters\" || -n \"$_arg_minimumSpecialCharacters\" ||\r\n  -n \"$_arg_passwordHistory\" ) &amp;&amp; \"$_arg_resetToDefaultPolicy\" == \"on\" ]]; then\r\n  _PRINT_HELP=yes die \"[Error] You cannot reset the policy back to the default policy and set a different policy at the same time.\" 1\r\nfi\r\n\r\n# Validate max login attempts. Ensure it is a positive integer greater than zero.\r\nif [[ -n \"$_arg_maxLoginAttempts\" ]]; then\r\n  _arg_maxLoginAttempts=$(echo \"$_arg_maxLoginAttempts\" | xargs)\r\n\r\n  if [[ -z \"$_arg_maxLoginAttempts\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid number of max login attempts was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_maxLoginAttempts\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for max login attempts was given: '$_arg_maxLoginAttempts'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_maxLoginAttempts\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for max login attempts was given: '$_arg_maxLoginAttempts'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Validate login attempt lock time. Ensure it is a positive integer greater than zero.\r\nif [[ -n \"$_arg_loginAttemptLockTime\" ]]; then\r\n  _arg_loginAttemptLockTime=$(echo \"$_arg_loginAttemptLockTime\" | xargs)\r\n\r\n  if [[ -z \"$_arg_loginAttemptLockTime\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid lock time was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_loginAttemptLockTime\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for lock time was given: '$_arg_loginAttemptLockTime'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_loginAttemptLockTime\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for lock time was given: '$_arg_loginAttemptLockTime'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Validate password expiration time. Ensure it is a positive whole number or zero for no expiration.\r\nif [[ -n \"$_arg_daysUntilPasswordExpiration\" ]]; then\r\n  _arg_daysUntilPasswordExpiration=$(echo \"$_arg_daysUntilPasswordExpiration\" | xargs)\r\n\r\n  if [[ -z \"$_arg_daysUntilPasswordExpiration\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid expiration time was given. Please specify a positive whole number or '0' for no expiration.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_daysUntilPasswordExpiration\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for password expiration was given: '$_arg_daysUntilPasswordExpiration'. Please specify a positive whole number or '0' for no expiration.\" 1\r\nfi\r\n\r\n# Validate minimum password length. Ensure it is a positive whole number greater than or equal to 8.\r\nif [[ -n \"$_arg_minimumPasswordLength\" ]]; then\r\n  _arg_minimumPasswordLength=$(echo \"$_arg_minimumPasswordLength\" | xargs)\r\n\r\n  if [[ -z \"$_arg_minimumPasswordLength\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid minimum password length was given. Please specify a positive whole number that is greater than or equal to '8'.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_minimumPasswordLength\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for minimum password length was given: '$_arg_minimumPasswordLength'. Please specify a positive whole number that is greater than or equal to 8.\" 1\r\nfi\r\nif [[ -n \"$_arg_minimumPasswordLength\" &amp;&amp; \"$_arg_minimumPasswordLength\" -lt 8 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for minimum password length was given: '$_arg_minimumPasswordLength'. Please specify a positive whole number that is greater than or equal to 8.\" 1\r\nfi\r\n\r\n# Validate the minimum number of digits. Ensure it is a positive whole number greater than zero.\r\nif [[ -n \"$_arg_minimumNumbersInPassword\" ]]; then\r\n  _arg_minimumNumbersInPassword=$(echo \"$_arg_minimumNumbersInPassword\" | xargs)\r\n\r\n  if [[ -z \"$_arg_minimumNumbersInPassword\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid minimum number of numbers was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_minimumNumbersInPassword\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of digits was given: '$_arg_minimumNumbersInPassword'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_minimumNumbersInPassword\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of digits was given: '$_arg_minimumNumbersInPassword'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Validate the minimum number of lowercase letters. Ensure it is a positive whole number greater than zero.\r\nif [[ -n \"$_arg_minimumLowercaseLetters\" ]]; then\r\n  _arg_minimumLowercaseLetters=$(echo \"$_arg_minimumLowercaseLetters\" | xargs)\r\n\r\n  if [[ -z \"$_arg_minimumLowercaseLetters\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid minimum number of lowercase letters was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_minimumLowercaseLetters\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of lowercase letters was given: '$_arg_minimumLowercaseLetters'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_minimumLowercaseLetters\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of lowercase letters was given: '$_arg_minimumLowercaseLetters'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Validate the minimum number of uppercase letters. Ensure it is a positive whole number greater than zero.\r\nif [[ -n \"$_arg_minimumUppercaseLetters\" ]]; then\r\n  _arg_minimumUppercaseLetters=$(echo \"$_arg_minimumUppercaseLetters\" | xargs)\r\n\r\n  if [[ -z \"$_arg_minimumUppercaseLetters\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid minimum number of uppercase letters was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_minimumUppercaseLetters\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid minimum number of uppercase letters was given of '$_arg_minimumUppercaseLetters'. Please specify a positive whole number that is greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_minimumUppercaseLetters\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid minimum number of uppercase letters was given of '$_arg_minimumUppercaseLetters'. Please specify a positive whole number that is greater than 0.\" 1\r\nfi\r\n\r\n# Validate the minimum number of special characters. Ensure it is a positive whole number greater than zero.\r\nif [[ -n \"$_arg_minimumSpecialCharacters\" ]]; then\r\n  _arg_minimumSpecialCharacters=$(echo \"$_arg_minimumSpecialCharacters\" | xargs)\r\n\r\n  if [[ -z \"$_arg_minimumSpecialCharacters\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid minimum number of special characters was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_minimumSpecialCharacters\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of special characters was given: '$_arg_minimumSpecialCharacters'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_minimumSpecialCharacters\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the minimum number of special characters was given: '$_arg_minimumSpecialCharacters'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Validate password history setting. Ensure it is a positive whole number greater than zero.\r\nif [[ -n \"$_arg_passwordHistory\" ]]; then\r\n  _arg_passwordHistory=$(echo \"$_arg_passwordHistory\" | xargs)\r\n\r\n  if [[ -z \"$_arg_passwordHistory\" ]]; then\r\n    _PRINT_HELP=yes die \"[Error] An invalid number of passwords to remember was given. Please specify a positive whole number that is greater than 0.\" 1\r\n  fi\r\nfi\r\nif [[ \"$_arg_passwordHistory\" =~ [^0-9] ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the number of passwords to remember was given: '$_arg_passwordHistory'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\nif [[ \"$_arg_passwordHistory\" == 0 ]]; then\r\n  _PRINT_HELP=yes die \"[Error] An invalid value for the number of passwords to remember was given: '$_arg_passwordHistory'. Please specify a positive whole number greater than 0.\" 1\r\nfi\r\n\r\n# Ensure that at least one password policy is being set. If none are provided and the reset flag is off, throw an error.\r\nif [[ -z \"$_arg_maxLoginAttempts\" &amp;&amp; -z \"$_arg_loginAttemptLockTime\" &amp;&amp; -z \"$_arg_daysUntilPasswordExpiration\" &amp;&amp; -z \"$_arg_minimumPasswordLength\" &amp;&amp;\r\n  -z \"$_arg_minimumNumbersInPassword\" &amp;&amp; -z \"$_arg_minimumLowercaseLetters\" &amp;&amp; -z \"$_arg_minimumUppercaseLetters\" &amp;&amp; -z \"$_arg_minimumSpecialCharacters\" &amp;&amp;\r\n  -z \"$_arg_passwordHistory\" &amp;&amp; \"$_arg_resetToDefaultPolicy\" == \"off\" ]]; then\r\n  _PRINT_HELP=yes die \"[Error] You must specify the password policy you are trying to set.\" 1\r\nfi\r\n\r\n# Define paths for the primary and secondary policy template files.\r\n_policyTemplateFilePath=\"\/tmp\/PwPolicy.plist\"\r\n_policyTemplateFilePath2=\"\/tmp\/PwPolicy2.plist\"\r\n\r\n# Reset To Default Policy\r\nif [[ $_arg_resetToDefaultPolicy == \"on\" ]]; then\r\n  # Notify that a default password policy file is being created.\r\n  echo \"Creating default password policy file.\"\r\n\r\n  # Create an XML plist file that contains only the default password policy.\r\n  echo \"&lt;?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?&gt;\r\n&lt;!DOCTYPE plist PUBLIC \\\"-\/\/Apple\/\/DTD PLIST 1.0\/\/EN\\\" \\\"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\\\"&gt;\r\n&lt;plist version=\\\"1.0\\\"&gt;\r\n&lt;dict&gt;\r\n    &lt;key&gt;policyCategoryPasswordContent&lt;\/key&gt;\r\n    &lt;array&gt;\r\n        &lt;dict&gt;\r\n            &lt;key&gt;policyContent&lt;\/key&gt;\r\n            &lt;string&gt;policyAttributePassword matches '^$|.{4,}+'&lt;\/string&gt;\r\n            &lt;key&gt;policyContentDescription&lt;\/key&gt;\r\n            &lt;dict&gt;\r\n                &lt;key&gt;ar&lt;\/key&gt;\r\n                &lt;string&gt;\u00d8\u00a3\u00d8\u00af\u00d8\u00ae\u00d9\u201e \u00d9\u0192\u00d9\u201e\u00d9\u2026\u00d8\u00a9 \u00d8\u00b3\u00d8\u00b1 \u00d9\u201e\u00d8\u00a7 \u00d8\u00aa\u00d9\u201a\u00d9\u201e \u00d8\u00b9\u00d9\u2020 \u00d8\u00a3\u00d8\u00b1\u00d8\u00a8\u00d8\u00b9\u00d8\u00a9 \u00d8\u00a3\u00d8\u00ad\u00d8\u00b1\u00d9\u0081 \u00d8\u00a3\u00d9\u02c6 \u00d8\u00b1\u00d9\u2026\u00d9\u02c6\u00d8\u00b2\u00d8\u0152 \u00d8\u00a3\u00d9\u02c6 \u00d8\u00a7\u00d8\u00aa\u00d8\u00b1\u00d9\u0192 \u00d8\u00ad\u00d9\u201a\u00d9\u201e \u00d9\u0192\u00d9\u201e\u00d9\u2026\u00d8\u00a9 \u00d8\u00a7\u00d9\u201e\u00d8\u00b3\u00d8\u00b1 \u00d9\u0081\u00d8\u00a7\u00d8\u00b1\u00d8\u00ba\u00d9\u2039\u00d8\u00a7.&lt;\/string&gt;\r\n                &lt;key&gt;ca&lt;\/key&gt;\r\n                &lt;string&gt;Introdueix una contrasenya que tingui quatre car\u00c3\u00a0cters o m\u00c3\u00a9s, o deixa el camp de la contrasenya en blanc.&lt;\/string&gt;\r\n                &lt;key&gt;cs&lt;\/key&gt;\r\n                &lt;string&gt;Zadejte heslo o\u00c2\u00a0minim\u00c3\u00a1ln\u00c3\u00ad d\u00c3\u00a9lce \u00c4\u008dty\u00c5\u2122i znaky nebo nechte pole hesla pr\u00c3\u00a1zdn\u00c3\u00a9.&lt;\/string&gt;\r\n                &lt;key&gt;da&lt;\/key&gt;\r\n                &lt;string&gt;Skriv en adgangskode p\u00c3\u00a5 mindst fire tegn, eller lad adgangskodefeltet v\u00c3\u00a6re tomt.&lt;\/string&gt;\r\n                &lt;key&gt;de&lt;\/key&gt;\r\n                &lt;string&gt;Gib ein Passwort ein, das aus mindestens vier Zeichen besteht, oder lass das Passwortfeld leer.&lt;\/string&gt;\r\n                &lt;key&gt;el&lt;\/key&gt;\r\n                &lt;string&gt;\u00ce\u2022\u00ce\u00b9\u00cf\u0192\u00ce\u00b1\u00ce\u00b3\u00ce\u00ac\u00ce\u00b3\u00ce\u00b5\u00cf\u201e\u00ce\u00b5 \u00ce\u00ad\u00ce\u00bd\u00ce\u00b1 \u00cf\u0192\u00cf\u2026\u00ce\u00bd\u00ce\u00b8\u00ce\u00b7\u00ce\u00bc\u00ce\u00b1\u00cf\u201e\u00ce\u00b9\u00ce\u00ba\u00cf\u0152 \u00cf\u20ac\u00ce\u00bf\u00cf\u2026 \u00ce\u00bd\u00ce\u00b1 \u00ce\u00b1\u00cf\u20ac\u00ce\u00bf\u00cf\u201e\u00ce\u00b5\u00ce\u00bb\u00ce\u00b5\u00ce\u00af\u00cf\u201e\u00ce\u00b1\u00ce\u00b9 \u00ce\u00b1\u00cf\u20ac\u00cf\u0152 \u00cf\u201e\u00ce\u00ad\u00cf\u0192\u00cf\u0192\u00ce\u00b5\u00cf\u0081\u00ce\u00b9\u00cf\u201a \u00ce\u00ae \u00cf\u20ac\u00ce\u00b5\u00cf\u0081\u00ce\u00b9\u00cf\u0192\u00cf\u0192\u00cf\u0152\u00cf\u201e\u00ce\u00b5\u00cf\u0081\u00ce\u00bf\u00cf\u2026\u00cf\u201a \u00cf\u2021\u00ce\u00b1\u00cf\u0081\u00ce\u00b1\u00ce\u00ba\u00cf\u201e\u00ce\u00ae\u00cf\u0081\u00ce\u00b5\u00cf\u201a, \u00ce\u00ae \u00ce\u00b1\u00cf\u2020\u00ce\u00ae\u00cf\u0192\u00cf\u201e\u00ce\u00b5 \u00cf\u201e\u00ce\u00bf \u00cf\u20ac\u00ce\u00b5\u00ce\u00b4\u00ce\u00af\u00ce\u00bf \u00cf\u201e\u00ce\u00bf\u00cf\u2026 \u00cf\u0192\u00cf\u2026\u00ce\u00bd\u00ce\u00b8\u00ce\u00b7\u00ce\u00bc\u00ce\u00b1\u00cf\u201e\u00ce\u00b9\u00ce\u00ba\u00ce\u00bf\u00cf\u008d \u00ce\u00ba\u00ce\u00b5\u00ce\u00bd\u00cf\u0152.&lt;\/string&gt;\r\n                &lt;key&gt;en&lt;\/key&gt;\r\n                &lt;string&gt;Enter a password that is four characters or more or leave the password field blank.&lt;\/string&gt;\r\n                &lt;key&gt;en_AU&lt;\/key&gt;\r\n                &lt;string&gt;Enter a password that is four characters or more or leave the password field blank.&lt;\/string&gt;\r\n                &lt;key&gt;en_GB&lt;\/key&gt;\r\n                &lt;string&gt;Enter a password that is four characters or more or leave the password field blank.&lt;\/string&gt;\r\n                &lt;key&gt;es&lt;\/key&gt;\r\n                &lt;string&gt;Introduce una contrase\u00c3\u00b1a que tenga cuatro caracteres como m\u00c3\u00adnimo o deja el campo de la contrase\u00c3\u00b1a en blanco.&lt;\/string&gt;\r\n                &lt;key&gt;es_419&lt;\/key&gt;\r\n                &lt;string&gt;Ingresa una contrase\u00c3\u00b1a de cuatro o m\u00c3\u00a1s caracteres, o deja el campo de contrase\u00c3\u00b1a en blanco.&lt;\/string&gt;\r\n                &lt;key&gt;fi&lt;\/key&gt;\r\n                &lt;string&gt;Kirjoita salasana, jossa on v\u00c3\u00a4hint\u00c3\u00a4\u00c3\u00a4n nelj\u00c3\u00a4 merkki\u00c3\u00a4, tai j\u00c3\u00a4t\u00c3\u00a4 salasanakentt\u00c3\u00a4 tyhj\u00c3\u00a4ksi.&lt;\/string&gt;\r\n                &lt;key&gt;fr&lt;\/key&gt;\r\n                &lt;string&gt;Saisissez un mot de passe comportant au moins quatre caract\u00c3\u00a8res ou laissez le champ vide.&lt;\/string&gt;\r\n                &lt;key&gt;fr_CA&lt;\/key&gt;\r\n                &lt;string&gt;Saisissez un mot de passe comportant au moins quatre caract\u00c3\u00a8res ou laissez le champ vide.&lt;\/string&gt;\r\n                &lt;key&gt;he&lt;\/key&gt;\r\n                &lt;string&gt;\u00d7\u2122\u00d7\u00a9 \u00d7\u0153\u00d7\u201d\u00d7\u2013\u00d7\u2122\u00d7\u0178 \u00d7\u00a1\u00d7\u2122\u00d7\u00a1\u00d7\u017e\u00d7\u201d \u00d7\u2018\u00d7\u00aa \u00d7\u0090\u00d7\u00a8\u00d7\u2018\u00d7\u00a2\u00d7\u201d \u00d7\u00aa\u00d7\u2022\u00d7\u2022\u00d7\u2122\u00d7\u009d \u00d7\u0153\u00d7\u00a4\u00d7\u2014\u00d7\u2022\u00d7\u00aa \u00d7\u0090\u00d7\u2022 \u00d7\u0153\u00d7\u201d\u00d7\u00a9\u00d7\u0090\u00d7\u2122\u00d7\u00a8 \u00d7\u0090\u00d7\u00aa \u00d7\u00a9\u00d7\u201c\u00d7\u201d \u00d7\u201d\u00d7\u00a1\u00d7\u2122\u00d7\u00a1\u00d7\u017e\u00d7\u201d \u00d7\u00a8\u00d7\u2122\u00d7\u00a7.&lt;\/string&gt;\r\n                &lt;key&gt;hi&lt;\/key&gt;\r\n                &lt;string&gt;\u00e0\u00a4\u0161\u00e0\u00a4\u00be\u00e0\u00a4\u00b0 \u00e0\u00a4\u00b5\u00e0\u00a4\u00b0\u00e0\u00a5\u008d\u00e0\u00a4\u00a3 \u00e0\u00a4\u00af\u00e0\u00a4\u00be \u00e0\u00a4\u2030\u00e0\u00a4\u00b8\u00e0\u00a4\u00b8\u00e0\u00a5\u2021 \u00e0\u00a4\u00ac\u00e0\u00a4\u00a1\u00e0\u00a4\u00bc\u00e0\u00a4\u00be \u00e0\u00a4\u00aa\u00e0\u00a4\u00be\u00e0\u00a4\u00b8\u00e0\u00a4\u00b5\u00e0\u00a4\u00b0\u00e0\u00a5\u008d\u00e0\u00a4\u00a1 \u00e0\u00a4\u00a6\u00e0\u00a4\u00b0\u00e0\u00a5\u008d\u00e0\u00a4\u0153 \u00e0\u00a4\u2022\u00e0\u00a4\u00b0\u00e0\u00a5\u2021\u00e0\u00a4\u201a \u00e0\u00a4\u00af\u00e0\u00a4\u00be \u00e0\u00a4\u00aa\u00e0\u00a4\u00be\u00e0\u00a4\u00b8\u00e0\u00a4\u00b5\u00e0\u00a4\u00b0\u00e0\u00a5\u008d\u00e0\u00a4\u00a1 \u00e0\u00a4\u00ab\u00e0\u00a4\u00bc\u00e0\u00a5\u20ac\u00e0\u00a4\u00b2\u00e0\u00a5\u008d\u00e0\u00a4\u00a1 \u00e0\u00a4\u2013\u00e0\u00a4\u00bc\u00e0\u00a4\u00be\u00e0\u00a4\u00b2\u00e0\u00a5\u20ac \u00e0\u00a4\u203a\u00e0\u00a5\u2039\u00e0\u00a4\u00a1\u00e0\u00a4\u00bc \u00e0\u00a4\u00a6\u00e0\u00a5\u2021\u00e0\u00a4\u201a\u00e0\u00a5\u00a4&lt;\/string&gt;\r\n                &lt;key&gt;hr&lt;\/key&gt;\r\n                &lt;string&gt;Unesite lozinku koja sadr\u00c5\u00bei minimalno \u00c4\u008detiri znaka ili polje lozinke ostavite prazno.&lt;\/string&gt;\r\n                &lt;key&gt;hu&lt;\/key&gt;\r\n                &lt;string&gt;Adjon meg egy legal\u00c3\u00a1bb n\u00c3\u00a9gy karakterb\u00c5\u2018l \u00c3\u00a1ll\u00c3\u00b3 jelsz\u00c3\u00b3t, vagy hagyja \u00c3\u00bcresen a jelsz\u00c3\u00b3mez\u00c5\u2018t.&lt;\/string&gt;\r\n                &lt;key&gt;id&lt;\/key&gt;\r\n                &lt;string&gt;Masukkan kata sandi yang terdiri dari empat karakter atau lebih atau kosongkan bidang kata sandi.&lt;\/string&gt;\r\n                &lt;key&gt;it&lt;\/key&gt;\r\n                &lt;string&gt;Inserisci una password di quattro o pi\u00c3\u00b9 caratteri o lascia vuoto il campo password.&lt;\/string&gt;\r\n                &lt;key&gt;ja&lt;\/key&gt;\r\n                &lt;string&gt;4\u00e6\u2013\u2021\u00e5\u00ad\u2014\u00e4\u00bb\u00a5\u00e4\u00b8\u0160\u00e3\u0081\u00ae\u00e3\u0192\u2018\u00e3\u201a\u00b9\u00e3\u0192\u00af\u00e3\u0192\u00bc\u00e3\u0192\u2030\u00e3\u201a\u2019\u00e5\u2026\u00a5\u00e5\u0160\u203a\u00e3\u0081\u2122\u00e3\u201a\u2039\u00e3\u0081\u2039\u00e3\u20ac\u0081\u00e3\u0192\u2018\u00e3\u201a\u00b9\u00e3\u0192\u00af\u00e3\u0192\u00bc\u00e3\u0192\u2030\u00e3\u0192\u2022\u00e3\u201a\u00a3\u00e3\u0192\u00bc\u00e3\u0192\u00ab\u00e3\u0192\u2030\u00e3\u201a\u2019\u00e7\u00a9\u00ba\u00e3\u0081\u00ae\u00e3\u0081\u00be\u00e3\u0081\u00be\u00e3\u0081\u00ab\u00e3\u0081\u2014\u00e3\u0081\u00a6\u00e3\u0081\u008f\u00e3\u0081\u00a0\u00e3\u0081\u2022\u00e3\u0081\u201e\u00e3\u20ac\u201a&lt;\/string&gt;\r\n                &lt;key&gt;ko&lt;\/key&gt;\r\n                &lt;string&gt;4\u00ec\u017e\u0090 \u00ec\u009d\u00b4\u00ec\u0192\u0081\u00ec\u009d\u02dc \u00ec\u2022\u201d\u00ed\u02dc\u00b8\u00eb\u00a5\u00bc \u00ec\u017e\u2026\u00eb\u00a0\u00a5\u00ed\u2022\u02dc\u00ea\u00b1\u00b0\u00eb\u201a\u02dc \u00ec\u2022\u201d\u00ed\u02dc\u00b8 \u00ed\u2022\u201e\u00eb\u201c\u0153\u00eb\u00a5\u00bc \u00eb\u00b9\u201e\u00ec\u203a\u0152\u00eb\u2018\u0090\u00ec\u2039\u00ad\u00ec\u2039\u0153\u00ec\u02dc\u00a4.&lt;\/string&gt;\r\n                &lt;key&gt;ms&lt;\/key&gt;\r\n                &lt;string&gt;Masukkan kata laluan sepanjang empat aksara atau lebih atau biarkan medan kata laluan kosong.&lt;\/string&gt;\r\n                &lt;key&gt;nl&lt;\/key&gt;\r\n                &lt;string&gt;Voer een wachtwoord van vier of meer tekens in of laat het wachtwoordveld leeg.&lt;\/string&gt;\r\n                &lt;key&gt;no&lt;\/key&gt;\r\n                &lt;string&gt;Angi et passord p\u00c3\u00a5 minst fire tegn, eller la passordfeltet st\u00c3\u00a5 tomt.&lt;\/string&gt;\r\n                &lt;key&gt;pl&lt;\/key&gt;\r\n                &lt;string&gt;Podaj has\u00c5\u201ao sk\u00c5\u201aadaj\u00c4\u2026ce si\u00c4\u2122 z\u00c2\u00a0co najmniej czterech znak\u00c3\u00b3w lub zostaw puste pole.&lt;\/string&gt;\r\n                &lt;key&gt;pt_BR&lt;\/key&gt;\r\n                &lt;string&gt;Digite uma senha com ao menos quatro caracteres ou deixe o campo de senha em branco.&lt;\/string&gt;\r\n                &lt;key&gt;pt_PT&lt;\/key&gt;\r\n                &lt;string&gt;Digite uma palavra\u00e2\u20ac\u2018passe com pelo menos quatro caracteres, ou deixe o campo da palavra\u00e2\u20ac\u2018passe em branco.&lt;\/string&gt;\r\n                &lt;key&gt;ro&lt;\/key&gt;\r\n                &lt;string&gt;Introduce\u00c8\u203ai o parol\u00c4\u0192 de minimum patru caractere sau l\u00c4\u0192sa\u00c8\u203ai gol c\u00c3\u00a2mpul pentru parol\u00c4\u0192.&lt;\/string&gt;\r\n                &lt;key&gt;ru&lt;\/key&gt;\r\n                &lt;string&gt;\u00d0\u2019\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d0\u00b8\u00d1\u201a\u00d0\u00b5 \u00d0\u00bf\u00d0\u00b0\u00d1\u20ac\u00d0\u00be\u00d0\u00bb\u00d1\u0152, \u00d1\u0081\u00d0\u00be\u00d1\u0081\u00d1\u201a\u00d0\u00be\u00d1\u008f\u00d1\u2030\u00d0\u00b8\u00d0\u00b9 \u00d0\u00b8\u00d0\u00b7 \u00d1\u2021\u00d0\u00b5\u00d1\u201a\u00d1\u2039\u00d1\u20ac\u00d0\u00b5\u00d1\u2026 \u00d0\u00b8\u00d0\u00bb\u00d0\u00b8 \u00d0\u00b1\u00d0\u00be\u00d0\u00bb\u00d0\u00b5\u00d0\u00b5 \u00d1\u0081\u00d0\u00b8\u00d0\u00bc\u00d0\u00b2\u00d0\u00be\u00d0\u00bb\u00d0\u00be\u00d0\u00b2, \u00d0\u00bb\u00d0\u00b8\u00d0\u00b1\u00d0\u00be \u00d0\u00be\u00d1\u0081\u00d1\u201a\u00d0\u00b0\u00d0\u00b2\u00d1\u0152\u00d1\u201a\u00d0\u00b5 \u00d0\u00bf\u00d0\u00be\u00d0\u00bb\u00d0\u00b5 \u00d0\u00bf\u00d0\u00b0\u00d1\u20ac\u00d0\u00be\u00d0\u00bb\u00d1\u008f \u00d0\u00bf\u00d1\u0192\u00d1\u0081\u00d1\u201a\u00d1\u2039\u00d0\u00bc.&lt;\/string&gt;\r\n                &lt;key&gt;sk&lt;\/key&gt;\r\n                &lt;string&gt;Zadajte heslo obsahuj\u00c3\u00bace najmenej \u00c5\u00a1tyri znaky alebo nechajte pole pre heslo pr\u00c3\u00a1zdne.&lt;\/string&gt;\r\n                &lt;key&gt;sv&lt;\/key&gt;\r\n                &lt;string&gt;Ange ett l\u00c3\u00b6senord som \u00c3\u00a4r minst fyra tecken l\u00c3\u00a5ngt eller l\u00c3\u00a5t l\u00c3\u00b6senordsf\u00c3\u00a4ltet vara tomt.&lt;\/string&gt;\r\n                &lt;key&gt;th&lt;\/key&gt;\r\n                &lt;string&gt;\u00e0\u00b8\u203a\u00e0\u00b9\u2030\u00e0\u00b8\u00ad\u00e0\u00b8\u2122\u00e0\u00b8\u00a3\u00e0\u00b8\u00ab\u00e0\u00b8\u00b1\u00e0\u00b8\u00aa\u00e0\u00b8\u0153\u00e0\u00b9\u02c6\u00e0\u00b8\u00b2\u00e0\u00b8\u2122\u00e0\u00b8\u2014\u00e0\u00b8\u00b5\u00e0\u00b9\u02c6\u00e0\u00b8\u00a1\u00e0\u00b8\u00b5\u00e0\u00b8\u00ad\u00e0\u00b8\u00b1\u00e0\u00b8\u0081\u00e0\u00b8\u201a\u00e0\u00b8\u00a3\u00e0\u00b8\u00b0\u00e0\u00b8\u00ad\u00e0\u00b8\u00a2\u00e0\u00b9\u02c6\u00e0\u00b8\u00b2\u00e0\u00b8\u2021\u00e0\u00b8\u2122\u00e0\u00b9\u2030\u00e0\u00b8\u00ad\u00e0\u00b8\u00a2\u00e0\u00b8\u00aa\u00e0\u00b8\u00b5\u00e0\u00b9\u02c6\u00e0\u00b8\u2022\u00e0\u00b8\u00b1\u00e0\u00b8\u00a7\u00e0\u00b8\u00ab\u00e0\u00b8\u00a3\u00e0\u00b8\u00b7\u00e0\u00b8\u00ad\u00e0\u00b9\u20ac\u00e0\u00b8\u00a7\u00e0\u00b9\u2030\u00e0\u00b8\u2122\u00e0\u00b8\u0160\u00e0\u00b9\u02c6\u00e0\u00b8\u00ad\u00e0\u00b8\u2021\u00e0\u00b8\u00a3\u00e0\u00b8\u00ab\u00e0\u00b8\u00b1\u00e0\u00b8\u00aa\u00e0\u00b8\u0153\u00e0\u00b9\u02c6\u00e0\u00b8\u00b2\u00e0\u00b8\u2122\u00e0\u00b9\u201e\u00e0\u00b8\u00a7\u00e0\u00b9\u2030&lt;\/string&gt;\r\n                &lt;key&gt;tr&lt;\/key&gt;\r\n                &lt;string&gt;En az d\u00c3\u00b6rt karakter uzunlu\u00c4\u0178unda bir parola girin veya parola alan\u00c4\u00b1n\u00c4\u00b1 bo\u00c5\u0178 b\u00c4\u00b1rak\u00c4\u00b1n.&lt;\/string&gt;\r\n                &lt;key&gt;uk&lt;\/key&gt;\r\n                &lt;string&gt;\u00d0\u2019\u00d0\u00b2\u00d0\u00b5\u00d0\u00b4\u00d1\u2013\u00d1\u201a\u00d1\u0152 \u00d0\u00bf\u00d0\u00b0\u00d1\u20ac\u00d0\u00be\u00d0\u00bb\u00d1\u0152 \u00d0\u00b7\u00d1\u2013 \u00d1\u2030\u00d0\u00be\u00d0\u00bd\u00d0\u00b0\u00d0\u00b9\u00d0\u00bc\u00d0\u00b5\u00d0\u00bd\u00d1\u02c6\u00d0\u00b5 \u00d1\u2021\u00d0\u00be\u00d1\u201a\u00d0\u00b8\u00d1\u20ac\u00d1\u0152\u00d0\u00be\u00d1\u2026 \u00d1\u0081\u00d0\u00b8\u00d0\u00bc\u00d0\u00b2\u00d0\u00be\u00d0\u00bb\u00d1\u2013\u00d0\u00b2 \u00d0\u00b0\u00d0\u00b1\u00d0\u00be \u00d0\u00b7\u00d0\u00b0\u00d0\u00bb\u00d0\u00b8\u00d1\u02c6\u00d1\u201a\u00d0\u00b5 \u00d0\u00bf\u00d0\u00be\u00d0\u00bb\u00d0\u00b5 \u00d0\u00bf\u00d0\u00b0\u00d1\u20ac\u00d0\u00be\u00d0\u00bb\u00d1\u008f \u00d0\u00bf\u00d1\u0192\u00d1\u0081\u00d1\u201a\u00d0\u00b8\u00d0\u00bc.&lt;\/string&gt;\r\n                &lt;key&gt;vi&lt;\/key&gt;\r\n                &lt;string&gt;Nh\u00e1\u00ba\u00adp m\u00e1\u00ba\u00adt kh\u00e1\u00ba\u00a9u d\u00c3\u00a0i 4 k\u00c3\u00bd t\u00e1\u00bb\u00b1 tr\u00e1\u00bb\u0178 l\u00c3\u00aan ho\u00e1\u00ba\u00b7c \u00c4\u2018\u00e1\u00bb\u0192 tr\u00e1\u00bb\u2018ng tr\u00c6\u00b0\u00e1\u00bb\u009dng m\u00e1\u00ba\u00adt kh\u00e1\u00ba\u00a9u.&lt;\/string&gt;\r\n                &lt;key&gt;zh_CN&lt;\/key&gt;\r\n                &lt;string&gt;\u00e8\u00be\u201c\u00e5\u2026\u00a5\u00e4\u00b8\u008d\u00e5\u00b0\u2018\u00e4\u00ba\u017d4\u00e4\u00b8\u00aa\u00e5\u00ad\u2014\u00e7\u00ac\u00a6\u00e7\u0161\u201e\u00e5\u00af\u2020\u00e7\u00a0\u0081\u00ef\u00bc\u0152\u00e6\u02c6\u2013\u00e5\u00b0\u2020\u00e5\u00af\u2020\u00e7\u00a0\u0081\u00e6\u00a0\u008f\u00e7\u2022\u2122\u00e7\u00a9\u00ba\u00e3\u20ac\u201a&lt;\/string&gt;\r\n                &lt;key&gt;zh_HK&lt;\/key&gt;\r\n                &lt;string&gt;\u00e8\u00bc\u00b8\u00e5\u2026\u00a5\u00e4\u00b8\u20ac\u00e5\u20ac\u2039\u00e5\u203a\u203a\u00e4\u00bd\u008d\u00e6\u02c6\u2013\u00e6\u203a\u00b4\u00e5\u00a4\u0161\u00e5\u00ad\u2014\u00e5\u2026\u0192\u00e7\u0161\u201e\u00e5\u00af\u2020\u00e7\u00a2\u00bc\u00ef\u00bc\u0152\u00e6\u02c6\u2013\u00e7\u2022\u2122\u00e7\u00a9\u00ba\u00e5\u00af\u2020\u00e7\u00a2\u00bc\u00e6\u00ac\u201e\u00e4\u00bd\u008d\u00e3\u20ac\u201a&lt;\/string&gt;\r\n                &lt;key&gt;zh_TW&lt;\/key&gt;\r\n                &lt;string&gt;\u00e8\u00bc\u00b8\u00e5\u2026\u00a54\u00e5\u20ac\u2039\u00e5\u00ad\u2014\u00e5\u2026\u0192\u00e6\u02c6\u2013\u00e6\u203a\u00b4\u00e9\u2022\u00b7\u00e7\u0161\u201e\u00e5\u00af\u2020\u00e7\u00a2\u00bc\u00ef\u00bc\u0152\u00e6\u02c6\u2013\u00e5\u00b0\u2021\u00e5\u00af\u2020\u00e7\u00a2\u00bc\u00e6\u00ac\u201e\u00e4\u00bd\u008d\u00e7\u2022\u2122\u00e7\u00a9\u00ba\u00e3\u20ac\u201a&lt;\/string&gt;\r\n            &lt;\/dict&gt;\r\n            &lt;key&gt;policyIdentifier&lt;\/key&gt;\r\n            &lt;string&gt;com.apple.defaultpasswordpolicy&lt;\/string&gt;\r\n        &lt;\/dict&gt;\r\n    &lt;\/array&gt;\r\n&lt;\/dict&gt;\r\n&lt;\/plist&gt;\" &gt;\"$_policyTemplateFilePath\"\r\n\r\n  # Attempt to apply the newly created password policy template.\r\n  # If the policy application fails, print an error and exit with a failure code.\r\n  echo \"Attempting to apply the policy template.\"\r\n  if ! pwpolicy -setaccountpolicies \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to update the password policy.\" 1\r\n  else\r\n    echo \"Successfully applied the default policy.\"\r\n    exit 0\r\n  fi\r\nfi\r\n\r\n# Display a message indicating that the password policy template is being created using the current policy.\r\necho \"Creating password policy template using current password policy.\"\r\n\r\n# Extract the current password policy and store it in the specified template file.\r\n# If extraction fails, print an error and exit.\r\nif ! pwpolicy -getaccountpolicies | tail -n \"+2\" &gt;\"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to get current password policy.\" 1\r\nfi\r\n\r\n# Read the current policy into a variable for further manipulation.\r\ncurrentPolicy=$(defaults read \"$_policyTemplateFilePath\" 2&gt;\/dev\/null)\r\n\r\n# Extract the maximum failed login attempts from the current policy, if it exists.\r\ncurrentMaxLoginAttempts=$(echo \"$currentPolicy\" | grep \"policyAttributeMaximumFailedAuthentications\" | grep -E -o '\\d+')\r\n\r\n# If lock time is set but max login attempts are not set in either argument or the current policy, show an error.\r\nif [[ -n \"$_arg_loginAttemptLockTime\" &amp;&amp; -z \"$_arg_maxLoginAttempts\" &amp;&amp; -z $currentMaxLoginAttempts ]]; then\r\n  _PRINT_HELP=no die \"[Error] Max login attempts are not currently set. Unable to set the login attempt lock time without the max login attempts being set.\" 1\r\nfi\r\n\r\n# Notify that the template creation process has been completed.\r\necho \"Template created.\"\r\necho \"\"\r\n\r\n# Check if the current policy includes an authentication category and add it if missing.\r\necho \"Verifying template contains Authentication category and adding insertion point.\"\r\npasswordAuthenticationKey=$(echo \"$currentPolicy\" | grep \"policyCategoryAuthentication\")\r\nif [[ -z \"$passwordAuthenticationKey\" ]]; then\r\n  # Add a placeholder to the policy template for inserting the authentication category.\r\n  if ! sed -i '' '\/&lt;plist version=\"1.0\"&gt;\/a\\\r\n    &lt;- dictionary line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Define the structure for the authentication category\r\n  newPasswordAuthenticationCategory=\"\r\n  &lt;key&gt;policyCategoryAuthentication&lt;\\\/key&gt;\r\n  &lt;array&gt;\r\n  &lt;\\\/array&gt;\"\r\n\r\n  # Format the new category into the template file.\r\n  newPasswordAuthenticationCategory=$(echo \"$newPasswordAuthenticationCategory\" | tr '\\n' '`')\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;.*&lt;dict.*\/&lt;- dictionary line will be replaced -&gt;&lt;dict&gt;$newPasswordAuthenticationCategory\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Convert back to newline-separated format, move the new file into place, and clean up.\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;\/\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\nfi\r\n\r\n# Check if the policy contains a password content category and add it if missing.\r\necho \"Verifying template contains Password Content category and adding insertion point.\"\r\npasswordContentKey=$(echo \"$currentPolicy\" | grep \"policyCategoryPasswordContent\")\r\nif [[ -z \"$passwordContentKey\" ]]; then\r\n  # Add a placeholder to the policy template for inserting the content category.\r\n  if ! sed -i '' '\/&lt;plist version=\"1.0\"&gt;\/a\\\r\n    &lt;- dictionary line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Define the structure for the content category\r\n  newPasswordContentCategory=\"\r\n  &lt;key&gt;policyCategoryPasswordContent&lt;\\\/key&gt;\r\n  &lt;array&gt;\r\n  &lt;\\\/array&gt;\"\r\n\r\n  # Format the new category into the template file.\r\n  newPasswordContentCategory=$(echo \"$newPasswordContentCategory\" | tr '\\n' '`')\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;.*&lt;dict.*\/&lt;- dictionary line will be replaced -&gt;&lt;dict&gt;$newPasswordContentCategory\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Convert back to newline-separated format, move the new file into place, and clean up.\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;\/\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\nfi\r\n\r\n# Check if the policy contains a password change category and add it if missing.\r\necho \"Verifying template contains Password Change category and adding insertion point.\"\r\npasswordChangeKey=$(echo \"$currentPolicy\" | grep \"policyCategoryPasswordChange\")\r\nif [[ -z \"$passwordChangeKey\" ]]; then\r\n  if ! sed -i '' '\/&lt;plist version=\"1.0\"&gt;\/a\\\r\n    &lt;- dictionary line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Define the structure for the change category\r\n  newPasswordChangeCategory=\"\r\n  &lt;key&gt;policyCategoryPasswordChange&lt;\\\/key&gt;\r\n  &lt;array&gt;\r\n  &lt;\\\/array&gt;\"\r\n\r\n  # Format the new category into the template file.\r\n  newPasswordChangeCategory=$(echo \"$newPasswordChangeCategory\" | tr '\\n' '`')\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;.*&lt;dict.*\/&lt;- dictionary line will be replaced -&gt;&lt;dict&gt;$newPasswordChangeCategory\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n\r\n  # Convert back to newline-separated format, move the new file into place, and clean up.\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\n  if ! sed -i '' \"s\/&lt;- dictionary line will be replaced -&gt;\/\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password policy.\" 1\r\n  fi\r\nfi\r\n\r\n# Add placeholders for inserting new password policies.\r\nif ! sed -i '' '\/&lt;key&gt;policyCategoryAuthentication&lt;\\\/key&gt;\/a\\\r\n  &lt;- PasswordAuthentication line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password authentication policies.\" 1\r\nfi\r\nif ! sed -i '' '\/&lt;key&gt;policyCategoryPasswordContent&lt;\\\/key&gt;\/a\\\r\n  &lt;- PasswordContent line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password content policies.\" 1\r\nfi\r\nif ! sed -i '' '\/&lt;key&gt;policyCategoryPasswordChange&lt;\\\/key&gt;\/a\\\r\n  &lt;- PasswordChange line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password change policies.\" 1\r\nfi\r\n\r\n# Verify if the Password Authentication category contains both opening and closing tags for the array.\r\necho \"Verifying Password Authentication category contains both opening and closing tag for the array.\"\r\npasswordAuthenticationClosingArray=$(grep '&lt;- PasswordAuthentication line will be replaced -&gt;.*&lt;array\/&gt;' \"$_policyTemplateFilePath\")\r\n\r\n# If the closing tag for the Password Authentication array is missing, add it.\r\nif [[ -n $passwordAuthenticationClosingArray ]]; then\r\n  if ! sed -i '' '\/&lt;- PasswordAuthentication line will be replaced -&gt;\/a\\\r\n  &lt;\\\/array&gt;' \"$_policyTemplateFilePath\"; then\r\n    # Print an error message and exit if adding the closing tag fails.\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password authentication policies.\" 1\r\n  fi\r\n\r\n  # Correct the opening tag for the array if necessary.\r\n  if ! sed -i '' 's\/&lt;- PasswordAuthentication line will be replaced -&gt;.*&lt;array\\\/&gt;\/&lt;- PasswordAuthentication line will be replaced -&gt; &lt;array&gt;\/g' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password authentication policies.\" 1\r\n  fi\r\nfi\r\n\r\n# Verify if the Password Content category contains both opening and closing tags for the array.\r\necho \"Verifying Password Content category contains both opening and closing tags for the array.\"\r\npasswordContentClosingArray=$(grep '&lt;- PasswordContent line will be replaced -&gt;.*&lt;array\/&gt;' \"$_policyTemplateFilePath\")\r\n\r\n# If the closing tag for the Password Content array is missing, add it.\r\nif [[ -n $passwordContentClosingArray ]]; then\r\n  if ! sed -i '' '\/&lt;- PasswordContent line will be replaced -&gt;\/a\\\r\n  &lt;\\\/array&gt;' \"$_policyTemplateFilePath\"; then\r\n    # Print an error message and exit if adding the closing tag fails.\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password content policies.\" 1\r\n  fi\r\n\r\n  # Correct the opening tag for the array if necessary.\r\n  if ! sed -i '' 's\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array\\\/&gt;\/&lt;- PasswordContent line will be replaced -&gt; &lt;array&gt;\/g' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password content policies.\" 1\r\n  fi\r\nfi\r\n\r\n# Verify if the Password Change category contains both opening and closing tags for the array.\r\necho \"Verifying Password Change category contains opening and closing tags for the array.\"\r\necho \"\"\r\npasswordChangeClosingArray=$(grep '&lt;- PasswordChange line will be replaced -&gt;.*&lt;array\/&gt;' \"$_policyTemplateFilePath\")\r\n\r\n# If the closing tag for the Password Change array is missing, add it.\r\nif [[ -n $passwordChangeClosingArray ]]; then\r\n  if ! sed -i '' '\/&lt;- PasswordChange line will be replaced -&gt;\/a\\\r\n  &lt;\\\/array&gt;' \"$_policyTemplateFilePath\"; then\r\n    # Print an error message and exit if adding the closing tag fails.\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password change policies.\" 1\r\n  fi\r\n\r\n  # Correct the opening tag for the array if necessary.\r\n  if ! sed -i '' 's\/&lt;- PasswordChange line will be replaced -&gt;.*&lt;array\\\/&gt;\/&lt;- PasswordChange line will be replaced -&gt; &lt;array&gt;\/g' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add insertion point for new password change policies.\" 1\r\n  fi\r\nfi\r\n\r\n# Max Login Attempts\r\nif [[ -n \"$_arg_maxLoginAttempts\" &amp;&amp; \"$currentMaxLoginAttempts\" == \"$_arg_maxLoginAttempts\" ]]; then\r\n  echo \"The password policy is already set to only allow $_arg_maxLoginAttempts failed attempts.\"\r\n  echo \"\"\r\n\r\n# If the maximum login attempts is set but does not match the current value, modify the policy.\r\nelif [[ -n \"$_arg_maxLoginAttempts\" &amp;&amp; -n \"$currentMaxLoginAttempts\" ]]; then\r\n  echo \"Attempting to change the password policy template from allowing $currentMaxLoginAttempts failed attempts to $_arg_maxLoginAttempts.\"\r\n\r\n  # Update the password policy template with the current maximum failed login attempts.\r\n  if ! sed -i '' \"s\/&lt;string&gt;[0-9]* max login attempts&lt;\\\/string&gt;\/&lt;string&gt;$currentMaxLoginAttempts max login attempts&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change failed login attempt policy.\" 1\r\n  fi\r\n\r\n  # Add a placeholder for the new maximum failed authentications setting.\r\n  if ! sed -i '' '\/&lt;key&gt;policyAttributeMaximumFailedAuthentications&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change failed login attempt policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the new maximum login attempts value.\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_maxLoginAttempts&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change failed login attempt policy.\" 1\r\n  fi\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n# If there is no current maximum login attempts policy, add a new one.\r\nelif [[ -n \"$_arg_maxLoginAttempts\" ]]; then\r\n  echo \"Attempting to set the password policy template to not allow more than $_arg_maxLoginAttempts failed attempts.\"\r\n\r\n  # Create a new policy block for failed login attempts.\r\n  new_passwordAttemptPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;(policyAttributeFailedAuthentications \\&amp;lt; policyAttributeMaximumFailedAuthentications)&lt;\\\/string&gt;\r\n  &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;$_arg_maxLoginAttempts max login attempts&lt;\\\/string&gt;\r\n  &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n  &lt;dict&gt;\r\n    &lt;key&gt;policyAttributeMaximumFailedAuthentications&lt;\\\/key&gt;\r\n    &lt;integer&gt;$_arg_maxLoginAttempts&lt;\\\/integer&gt;\r\n  &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Replace the placeholder with the new failed login attempts policy.\r\n  new_passwordAttemptPolicy=$(echo \"$new_passwordAttemptPolicy\" | tr '\\n' '`')\r\n  if ! sed -i '' \"s\/&lt;- PasswordAuthentication line will be replaced -&gt;.*&lt;.*array.*&gt;\/&lt;- PasswordAuthentication line will be replaced -&gt;&lt;array&gt;$new_passwordAttemptPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new failed password attempt policy.\" 1\r\n  fi\r\n\r\n  # Process the template by replacing backticks with newlines.\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new failed password attempt policy.\" 1\r\n  fi\r\n\r\n  # Move the modified template to the original path.\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new failed password attempt policy.\" 1\r\n  fi\r\n\r\n  echo \"Successfully added the new password policy to the template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Login Attempt Lock Time\r\nif [[ -n \"$_arg_loginAttemptLockTime\" ]]; then\r\n  # Extract the current lock time from the policy in seconds.\r\n  currentLoginAttemptLockTime=$(echo \"$currentPolicy\" | grep \"autoEnableInSeconds\" | grep -E -o '\\d+')\r\n\r\n  # Convert the current lock time from seconds to minutes.\r\n  if [[ -n $currentLoginAttemptLockTime ]]; then\r\n    currentLoginAttemptLockTime=$((currentLoginAttemptLockTime \/ 60))\r\n  fi\r\nfi\r\n\r\n# If the current lock time matches the provided lock time argument, no changes are needed.\r\nif [[ -n \"$_arg_loginAttemptLockTime\" &amp;&amp; $currentLoginAttemptLockTime == \"$_arg_loginAttemptLockTime\" ]]; then\r\n  echo \"The failed attempt lock time is already set to $_arg_loginAttemptLockTime minutes.\"\r\n  echo \"\"\r\n\r\n# If a lock time argument is provided, but the current lock time is different or not set, modify the policy.\r\nelif [[ -n \"$_arg_loginAttemptLockTime\" &amp;&amp; -n \"$currentLoginAttemptLockTime\" ]]; then\r\n  echo \"Attempting to change the failed login attempt lock time from $currentLoginAttemptLockTime to $_arg_loginAttemptLockTime minutes.\"\r\n\r\n  # Convert the new lock time from minutes to seconds.\r\n  _arg_loginAttemptLockTime=$((_arg_loginAttemptLockTime * 60))\r\n\r\n  # Add a placeholder for the new autoEnableInSeconds value in the policy template.\r\n  if ! sed -i '' '\/&lt;key&gt;autoEnableInSeconds&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the new lock time value in seconds.\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_loginAttemptLockTime&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If there is no current lock time, set a new failed attempt lock time in the policy.\r\nelif [[ -n \"$_arg_loginAttemptLockTime\" ]]; then\r\n  echo \"Attempting to set the failed password attempt lock time to $_arg_loginAttemptLockTime minutes.\"\r\n\r\n  # Convert the lock time from minutes to seconds for the policy.\r\n  _arg_loginAttemptLockTime=$((_arg_loginAttemptLockTime * 60))\r\n\r\n  # Modify the policy's string to include the new lock time condition.\r\n  if ! sed -i '' \"s\/&lt;string&gt;(policyAttributeFailedAuthentications \\&amp;lt; policyAttributeMaximumFailedAuthentications).*&lt;\\\/string&gt;\/&lt;string&gt;(policyAttributeFailedAuthentications \\&amp;lt; policyAttributeMaximumFailedAuthentications) OR (policyAttributeCurrentTime \\&amp;gt; (policyAttributeLastFailedAuthenticationTime + autoEnableInSeconds))&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  # Prepare a new policy block with the updated lockout time in seconds.\r\n  new_passwordLockoutTime=\"&lt;key&gt;autoEnableInSeconds&lt;\\\/key&gt;\r\n&lt;integer&gt;$_arg_loginAttemptLockTime&lt;\\\/integer&gt;\"\r\n  new_passwordLockoutTime=$(echo \"$new_passwordLockoutTime\" | tr '\\n' '`')\r\n\r\n  # Insert the new lockout time into the policy template.\r\n  if ! sed -i '' \"s\/&lt;key&gt;policyAttributeMaximumFailedAuthentications&lt;\\\/key&gt;\/$new_passwordLockoutTime$()&lt;key&gt;policyAttributeMaximumFailedAuthentications&lt;\\\/key&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  # Convert the processed backticks into newlines and create a temporary file.\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  # Replace the original policy template with the modified version.\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password lock time.\" 1\r\n  fi\r\n\r\n  echo \"Successfully added the new password policy to the template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Days Until Password Expiration\r\nif [[ -n \"$_arg_daysUntilPasswordExpiration\" ]]; then\r\n\r\n  # Extract the current password expiration setting from the policy\r\n  currentPasswordExpiration=$(echo \"$currentPolicy\" | grep \"policyAttributeExpiresEveryNDays\" | tail -n 1 | grep -E -o '\\d+')\r\n\r\n  # If the argument is set to 0 (never expire) and no expiration policy exists, notify the user\r\n  if [[ \"$_arg_daysUntilPasswordExpiration\" == 0 &amp;&amp; -z \"$currentPasswordExpiration\" ]]; then\r\n    echo \"The passwords are already set to never expire.\"\r\n  fi\r\n\r\n  # If the argument is set to 0 (never expire) and an expiration policy exists, attempt to remove it\r\n  if [[ \"$_arg_daysUntilPasswordExpiration\" == 0 &amp;&amp; -n \"$currentPasswordExpiration\" ]]; then\r\n    echo \"Attempting to remove password expiration policy so that passwords never expire.\"\r\n\r\n    # Use awk to find and mark the section of the policy that deals with password expiration for deletion\r\n    awk '\r\n    \/&lt;string&gt;policyAttributeCurrentTime &amp;gt; policyAttributeLastPasswordChangeTime \\+ \\(policyAttributeExpiresEveryNDays \\* 24 \\* 60 \\* 60\\)&lt;\\\/string&gt;\/ &amp;&amp; !appended {\r\n        print two_lines_ago \"&lt;- This opening dict will be deleted -&gt;\"\r\n        print one_line_ago\r\n        print $0\r\n        appended = 1\r\n        next\r\n    }\r\n    NR &gt; 2 {\r\n        print two_lines_ago\r\n    }\r\n    {\r\n        two_lines_ago = one_line_ago\r\n        one_line_ago = $0\r\n    }\r\n    END {\r\n        if (NR &gt; 1) print one_line_ago\r\n        if (NR &gt; 0) print $0\r\n    }\r\n' \"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"\r\n\r\n    # Ensure the plist file ends with the correct closing tag\r\n    if ! grep \"&lt;\/plist&gt;\" \"$_policyTemplateFilePath2\"; then\r\n      echo \"&lt;\/plist&gt;\" &gt;&gt;\"$_policyTemplateFilePath2\"\r\n    fi\r\n\r\n    # Mark the closing part of the expiration policy for deletion using sed\r\n    if ! sed -i '' '\/&lt;key&gt;policyAttributeExpiresEveryNDays&lt;\\\/key&gt;\/{n; n; n; s\/$\/ &lt;- This closing dict will be deleted -&gt;\/;}' \"$_policyTemplateFilePath2\"; then\r\n      _PRINT_HELP=no die \"[Error] Failed to remove password expiration policy.\" 1\r\n    fi\r\n\r\n    # Remove the marked sections from the policy using awk\r\n    if ! awk '\/&lt;dict&gt;&lt;- This opening dict will be deleted -&gt;\/{inblock=1} \/&lt;\\\/dict&gt;.*&lt;- This closing dict will be deleted -&gt;\/{inblock=0; next} !inblock {print}' \"$_policyTemplateFilePath2\" &gt;\"$_policyTemplateFilePath\"; then\r\n      _PRINT_HELP=no die \"[Error] Failed to remove password expiration policy.\" 1\r\n    fi\r\n\r\n    # Clean up by removing the temporary file\r\n    if [[ -f \"$_policyTemplateFilePath2\" ]]; then\r\n      rm \"$_policyTemplateFilePath2\"\r\n    fi\r\n\r\n    echo \"Successfully removed the password expiration policy from the template.\"\r\n    echo \"\"\r\n  fi\r\n\r\n  # If the argument is set to 0, clear the value of the expiration argument\r\n  if [[ \"$_arg_daysUntilPasswordExpiration\" == 0 ]]; then\r\n    _arg_daysUntilPasswordExpiration=\r\n  fi\r\nfi\r\n\r\n# Check if a value for days until password expiration is provided and if it matches the current policy\r\nif [[ -n \"$_arg_daysUntilPasswordExpiration\" &amp;&amp; \"$currentPasswordExpiration\" == \"$_arg_daysUntilPasswordExpiration\" ]]; then\r\n  # Notify the user if the current password expiration policy already matches the desired setting\r\n  echo \"The password expiration policy is already set to require a password change every $_arg_daysUntilPasswordExpiration day(s).\"\r\n  echo \"\"\r\n\r\n# If the desired expiration policy differs from the current one, attempt to update it\r\nelif [[ -n \"$_arg_daysUntilPasswordExpiration\" &amp;&amp; -n \"$currentPasswordExpiration\" ]]; then\r\n  echo \"Attempting to change the password expiration policy from requiring a password change every $currentPasswordExpiration days to $_arg_daysUntilPasswordExpiration days.\"\r\n\r\n  # Update the password expiration string in the policy template\r\n  if ! sed -i '' \"s\/&lt;string&gt;Change every .* days&lt;\\\/string&gt;\/&lt;string&gt;Change every $_arg_daysUntilPasswordExpiration days&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password expiration policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder in the policy template for the expiration integer\r\n  if ! sed -i '' '\/&lt;key&gt;policyAttributeExpiresEveryNDays&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password expiration policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the new expiration value\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_daysUntilPasswordExpiration&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password expiration policy.\" 1\r\n  fi\r\n\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no expiration policy exists, create a new one\r\nelif [[ -n \"$_arg_daysUntilPasswordExpiration\" ]]; then\r\n  echo \"Attempting to set the password expiration policy to require a password change every $_arg_daysUntilPasswordExpiration days.\"\r\n\r\n  # Define the new password expiration policy as a string\r\n  new_passwordExpirationPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributeCurrentTime \\&amp;gt; policyAttributeLastPasswordChangeTime + (policyAttributeExpiresEveryNDays * 24 * 60 * 60)&lt;\\\/string&gt;\r\n  &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Change every $_arg_daysUntilPasswordExpiration days&lt;\\\/string&gt;\r\n  &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n  &lt;dict&gt;\r\n    &lt;key&gt;policyAttributeExpiresEveryNDays&lt;\\\/key&gt;\r\n    &lt;integer&gt;$_arg_daysUntilPasswordExpiration&lt;\\\/integer&gt;\r\n  &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Add the new policy to the template in the appropriate location\r\n  new_passwordExpirationPolicy=$(echo \"$new_passwordExpirationPolicy\" | tr '\\n' '`')\r\n  if ! sed -i '' \"s\/&lt;- PasswordChange line will be replaced -&gt;.*&lt;.*array.*&gt;\/&lt;- PasswordChange line will be replaced -&gt;&lt;array&gt;$new_passwordExpirationPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password expiration policy.\" 1\r\n  fi\r\n\r\n  # Replace placeholders with the actual new policy in the template\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password expiration policy.\" 1\r\n  fi\r\n\r\n  # Move the updated policy template to its correct location\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password expiration policy.\" 1\r\n  fi\r\n\r\n  echo \"Successfully added the new password policy to the template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Minimum Password Length\r\nif [[ -n \"$_arg_minimumPasswordLength\" ]]; then\r\n  # Search for the default Apple password policy in the current policy\r\n  defaultPolicy=$(echo \"$currentPolicy\" | grep 'com.apple.defaultpasswordpolicy')\r\n\r\n  # If the default Apple password policy is found, proceed with its removal\r\n  if [[ -n \"$defaultPolicy\" ]]; then\r\n    # Use awk to mark lines for removal where the default password length policy is defined\r\n    awk '\r\n    \/&lt;string&gt;policyAttributePassword matches '\\''\\^\\$|\\.{4,}\\+'\\''&lt;\\\/string&gt;\/ &amp;&amp; !appended {\r\n        print two_lines_ago \"&lt;- This opening dict will be deleted -&gt;\"\r\n        print one_line_ago\r\n        print $0\r\n        appended = 1\r\n        next\r\n    }\r\n    NR &gt; 2 {\r\n        print two_lines_ago\r\n    }\r\n    {\r\n        two_lines_ago = one_line_ago\r\n        one_line_ago = $0\r\n    }\r\n    END {\r\n        if (NR &gt; 1) print one_line_ago\r\n        if (NR &gt; 0) print $0\r\n    }\r\n' \"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"\r\n\r\n    # Ensure the plist has the proper closing tag, add one if missing\r\n    if ! grep \"&lt;\/plist&gt;\" \"$_policyTemplateFilePath2\"; then\r\n      echo \"&lt;\/plist&gt;\" &gt;&gt;\"$_policyTemplateFilePath2\"\r\n    fi\r\n\r\n    # Insert a placeholder to mark the closing dictionary for deletion\r\n    if ! sed -i '' '\/&lt;string&gt;com.apple.defaultpasswordpolicy&lt;\\\/string&gt;\/a\\\r\n    &lt;- This closing dict will be deleted -&gt;' \"$_policyTemplateFilePath2\"; then\r\n      _PRINT_HELP=no die \"[Error] Failed to remove default password length policy.\" 1\r\n    fi\r\n\r\n    # Remove both opening and closing dictionaries marked for deletion\r\n    if ! awk '\/&lt;dict&gt;&lt;- This opening dict will be deleted -&gt;\/{inblock=1} \/&lt;- This closing dict will be deleted -&gt;.*&lt;\\\/dict&gt;\/{inblock=0; next} !inblock {print}' \"$_policyTemplateFilePath2\" &gt;\"$_policyTemplateFilePath\"; then\r\n      _PRINT_HELP=no die \"[Error] Failed to remove default password length policy.\" 1\r\n    fi\r\n\r\n    # Clean up by removing the temporary file used during the policy changes\r\n    if [[ -f \"$_policyTemplateFilePath2\" ]]; then\r\n      rm \"$_policyTemplateFilePath2\"\r\n    fi\r\n\r\n    # Set the current minimum password length to empty as the default policy is now removed\r\n    currentMinimumLength=\r\n\r\n  # If no default policy is found, check for a custom minimum length in the current policy\r\n  else\r\n    currentMinimumLength=$(echo \"$currentPolicy\" | grep \"minimumLength\" | grep -E -o '\\d+')\r\n  fi\r\nfi\r\n\r\n# Check if the provided minimum password length matches the current policy\r\nif [[ -n \"$_arg_minimumPasswordLength\" &amp;&amp; \"$currentMinimumLength\" == \"$_arg_minimumPasswordLength\" ]]; then\r\n  # Inform the user if the policy is already set to the desired minimum length\r\n  echo \"The password policy is already set to require a minimum length of $_arg_minimumPasswordLength character(s).\"\r\n  echo \"\"\r\n\r\n# If a new minimum password length is provided but no current length is set, and there's no default policy\r\nelif [[ -n \"$_arg_minimumPasswordLength\" &amp;&amp; -n \"$currentMinimumLength\" &amp;&amp; -z \"$defaultPolicy\" ]]; then\r\n  # Inform the user that the password policy is being changed\r\n  echo \"Attempting to change the password policy from a minimum character length of $currentMinimumLength to $_arg_minimumPasswordLength.\"\r\n\r\n  # Update the policy attribute to the new minimum length\r\n  if ! sed -i '' \"s\/&lt;string&gt;policyAttributePassword matches '\\.{[0-9]*,}.*'&lt;\\\/string&gt;\/&lt;string&gt;policyAttributePassword matches '.{$_arg_minimumPasswordLength,}\\+'&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password length policy.\" 1\r\n  fi\r\n\r\n  # Update the policy description to reflect the new minimum length\r\n  if ! sed -i '' \"s\/&lt;string&gt;Must be a minimum of [0-9]* characters.*&lt;\\\/string&gt;\/&lt;string&gt;Must be a minimum of $_arg_minimumPasswordLength characters in length&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password length policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder for the new integer value for the minimum length\r\n  if ! sed -i '' '\/&lt;key&gt;minimumLength&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password length policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual new minimum length integer value\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_minimumPasswordLength&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password length policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the policy modification was successful\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no current policy is set and a new minimum password length is provided, set a new policy \r\nelif [[ -n \"$_arg_minimumPasswordLength\" ]]; then\r\n  # Inform the user that a new policy is being set\r\n  echo \"Attempting to set the password policy to require a minimum character length of $_arg_minimumPasswordLength.\"\r\n\r\n  # Create a new password policy template with the specified minimum password length\r\n  new_passwordLengthPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributePassword matches '.{$_arg_minimumPasswordLength,}+'&lt;\\\/string&gt;\r\n    &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Must be a minimum of $_arg_minimumPasswordLength characters in length&lt;\\\/string&gt;\r\n    &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;minimumLength&lt;\\\/key&gt;\r\n        &lt;integer&gt;$_arg_minimumPasswordLength&lt;\\\/integer&gt;\r\n    &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy by converting it for insertion into the policy template\r\n  new_passwordLengthPolicy=$(echo \"$new_passwordLengthPolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new password policy into the appropriate section of the policy template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordLengthPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template and write changes to a new file\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original policy template file\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new password policy was successfully added to the template\r\n  echo \"Successfully added the new password policy to the template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Minimum Numbers\r\nif [[ -n \"$_arg_minimumNumbersInPassword\" ]]; then\r\n  # Retrieve the current minimum number of numeric characters from the policy if it exists\r\n  currentMinimumNumbers=$(echo \"$currentPolicy\" | grep \"minimumNumericCharacters\" | grep -E -o '\\d+')\r\nfi\r\n\r\n# If the provided number of numeric characters matches the current policy, inform the user\r\nif [[ -n \"$_arg_minimumNumbersInPassword\" &amp;&amp; \"$currentMinimumNumbers\" == \"$_arg_minimumNumbersInPassword\" ]]; then\r\n  echo \"The password policy is already set to require a minimum of $_arg_minimumNumbersInPassword numeric characters.\"\r\n  echo \"\"\r\n\r\n# If the provided number of numeric characters is different from the current policy, attempt to change it \r\nelif [[ -n \"$_arg_minimumNumbersInPassword\" &amp;&amp; -n \"$currentMinimumNumbers\" ]]; then\r\n  echo \"Attempting to change the password policy from requiring a minimum number of numeric characters of $currentMinimumNumbers to $_arg_minimumNumbersInPassword.\"\r\n\r\n  # Update the password policy to reflect the new minimum number of numeric characters\r\n  if ! sed -i '' \"s\/&lt;string&gt;policyAttributePassword matches '(\\.\\*\\?\\\\\\\\\\\\\\p{Nd}\\.\\*\\?){[0-9]*,}\\?'&lt;\\\/string&gt;\/&lt;string&gt;policyAttributePassword matches '(.*?\\\\\\\\\\\\\\p{Nd}.*?){$_arg_minimumNumbersInPassword,}?'&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum numbers password policy.\" 1\r\n  fi\r\n\r\n  # Update the policy description to indicate the new minimum number of numeric characters\r\n  if ! sed -i '' \"s\/&lt;string&gt;Must contain at least [0-9]* number.*&lt;\\\/string&gt;\/&lt;string&gt;Must contain at least $_arg_minimumNumbersInPassword number(s)&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum numbers password policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder for the new integer value for the minimum number of numeric characters\r\n  if ! sed -i '' '\/&lt;key&gt;minimumNumericCharacters&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum numbers password policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual integer value of the minimum number of numeric characters\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_minimumNumbersInPassword&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum numbers password policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the password policy template was successfully modified\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no current policy exists, create and set a new minimum number of numeric characters in the password\r\nelif [[ -n \"$_arg_minimumNumbersInPassword\" ]]; then\r\n  echo \"Attempting to set the password policy to requiring a minimum number of $_arg_minimumNumbersInPassword numeric characters.\"\r\n\r\n  # Create a new policy block with the specified minimum number of numeric characters\r\n  new_passwordNumberPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributePassword matches '(.*?\\\\\\\\\\\\\\p{Nd}.*?){$_arg_minimumNumbersInPassword,}?'&lt;\\\/string&gt;\r\n    &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Must contain at least $_arg_minimumNumbersInPassword number(s)&lt;\\\/string&gt;\r\n    &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;minimumNumericCharacters&lt;\\\/key&gt;\r\n        &lt;integer&gt;$_arg_minimumNumbersInPassword&lt;\\\/integer&gt;\r\n    &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy block for insertion into the policy template\r\n  new_passwordNumberPolicy=$(echo \"$new_passwordNumberPolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new policy block at the appropriate point in the template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordNumberPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum numbers policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template for saving\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum numbers policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original template\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum numbers policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new password policy was successfully added to the template\r\n  echo \"Successfully added the new password policy to the template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Minimum Lowercase Letters\r\nif [[ -n \"$_arg_minimumLowercaseLetters\" ]]; then\r\n  # Extract the current minimum number of lowercase letters from the current policy\r\n  currentMinimumLowercaseLetters=$(echo \"$currentPolicy\" | grep \"minimumAlphaCharactersLowerCase\" | grep -E -o '\\d+')\r\nfi\r\n\r\n# If the current policy already matches the user-provided minimum, inform the user\r\nif [[ -n \"$_arg_minimumLowercaseLetters\" &amp;&amp; \"$currentMinimumLowercaseLetters\" == \"$_arg_minimumLowercaseLetters\" ]]; then\r\n  echo \"The password policy is already set to require a minimum of $_arg_minimumLowercaseLetters lowercase characters.\"\r\n  echo \"\"\r\n\r\n# If the current policy doesn't match, attempt to modify it\r\nelif [[ -n \"$_arg_minimumLowercaseLetters\" &amp;&amp; -n \"$currentMinimumLowercaseLetters\" ]]; then\r\n  echo \"Attempting to change the password policy from a minimum of $currentMinimumLowercaseLetters lowercase characters to $_arg_minimumLowercaseLetters.\"\r\n\r\n  # Update the regex pattern for password validation to enforce the new number of lowercase letters\r\n  if ! sed -i '' \"s\/&lt;string&gt;policyAttributePassword matches '(\\.\\*\\[a-z\\]\\.\\*){[0-9]*,}\\+'&lt;\\\/string&gt;\/&lt;string&gt;policyAttributePassword matches '(.*[a-z].*){$_arg_minimumLowercaseLetters,}+'&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of lower case letters password policy.\" 1\r\n  fi\r\n\r\n  # Update the description to indicate the new minimum number of lowercase letters\r\n  if ! sed -i '' \"s\/&lt;string&gt;Must contain at least [0-9]* lower case.*&lt;\\\/string&gt;\/&lt;string&gt;Must contain at least $_arg_minimumLowercaseLetters lower case letter(s)&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of lower case letters password policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder for the new integer value for the minimum number of lowercase letters\r\n  if ! sed -i '' '\/&lt;key&gt;minimumAlphaCharactersLowerCase&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of lower case letters password policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual integer value for the minimum number of lowercase letters\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_minimumLowercaseLetters&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of lower case letters password policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the password policy template was successfully modified\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no current policy exists, create and set a new policy for the minimum number of lowercase letters\r\nelif [[ -n \"$_arg_minimumLowercaseLetters\" ]]; then\r\n  echo \"Attempting to set the password policy to require a minimum of $_arg_minimumLowercaseLetters lowercase characters.\"\r\n\r\n  # Create a new policy block with the specified minimum number of lowercase letters\r\n  new_passwordLowerCasePolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributePassword matches '(.*[a-z].*){$_arg_minimumLowercaseLetters,}+'&lt;\\\/string&gt;\r\n    &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Must contain at least $_arg_minimumLowercaseLetters lower case letter(s)&lt;\\\/string&gt;\r\n    &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;minimumAlphaCharactersLowerCase&lt;\\\/key&gt;\r\n        &lt;integer&gt;$_arg_minimumLowercaseLetters&lt;\\\/integer&gt;\r\n    &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy block for insertion into the policy template\r\n  new_passwordLowerCasePolicy=$(echo \"$new_passwordLowerCasePolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new policy block at the appropriate point in the template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordLowerCasePolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum lower case letters policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template for saving\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum lower case letters policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original template\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum lower case letters policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new password policy was successfully added to the template\r\n  echo \"Successfully added the new policy to the password template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Minimum Uppercase Letters\r\nif [[ -n \"$_arg_minimumUppercaseLetters\" ]]; then\r\n  # Extract the current minimum number of uppercase letters from the current policy\r\n  currentMinimumUppercaseLetters=$(echo \"$currentPolicy\" | grep -w \"minimumAlphaCharacters\" | grep -E -o '\\d+')\r\nfi\r\n\r\n# If the current policy already matches the user-provided minimum, inform the user\r\nif [[ -n \"$_arg_minimumUppercaseLetters\" &amp;&amp; \"$currentMinimumUppercaseLetters\" == \"$_arg_minimumUppercaseLetters\" ]]; then\r\n  echo \"The password policy is already set to require a minimum of $_arg_minimumUppercaseLetters uppercase characters.\"\r\n  echo \"\"\r\n\r\n# If the current policy doesn't match, attempt to modify it\r\nelif [[ -n \"$_arg_minimumUppercaseLetters\" &amp;&amp; -n \"$currentMinimumUppercaseLetters\" ]]; then\r\n  echo \"Attempting to change the password policy from a minimum of $currentMinimumUppercaseLetters uppercase characters to $_arg_minimumUppercaseLetters.\"\r\n\r\n  # Update the regex pattern for password validation to enforce the new number of uppercase letters\r\n  if ! sed -i '' \"s\/&lt;string&gt;policyAttributePassword matches '(\\.\\*\\[A-Z\\]\\.\\*){[0-9]*,}\\+'&lt;\\\/string&gt;\/&lt;string&gt;policyAttributePassword matches '(.*[A-Z].*){$_arg_minimumUppercaseLetters,}+'&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of upper case letters password policy.\" 1\r\n  fi\r\n\r\n  # Update the description to indicate the new minimum number of uppercase letters\r\n  if ! sed -i '' \"s\/&lt;string&gt;Must contain at least [0-9]* upper case.*&lt;\\\/string&gt;\/&lt;string&gt;Must contain at least $_arg_minimumUppercaseLetters upper case letter(s)&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of upper case letters password policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder for the new integer value for the minimum number of uppercase letters\r\n  if ! sed -i '' '\/&lt;key&gt;minimumAlphaCharacters&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of upper case letters password policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual integer value for the minimum number of uppercase letters\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_minimumUppercaseLetters&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of upper case letters password policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the password policy template was successfully modified\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no current policy exists, create and set a new policy for the minimum number of uppercase letters\r\nelif [[ -n \"$_arg_minimumUppercaseLetters\" ]]; then\r\n  echo \"Attempting to set the password policy to require a minimum of $_arg_minimumUppercaseLetters uppercase characters.\"\r\n\r\n  # Create a new policy block with the specified minimum number of uppercase letters\r\n  new_passwordUpperCasePolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributePassword matches '(.*[A-Z].*){$_arg_minimumUppercaseLetters,}+'&lt;\\\/string&gt;\r\n    &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Must contain at least $_arg_minimumUppercaseLetters upper case letter(s)&lt;\\\/string&gt;\r\n    &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;minimumAlphaCharacters&lt;\\\/key&gt;\r\n        &lt;integer&gt;$_arg_minimumUppercaseLetters&lt;\\\/integer&gt;\r\n    &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy block for insertion into the policy template\r\n  new_passwordUpperCasePolicy=$(echo \"$new_passwordUpperCasePolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new policy block at the appropriate point in the template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordUpperCasePolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum upper case letters policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template for saving\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum upper case letters policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original template\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum upper case letters policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new password policy was successfully added to the template\r\n  echo \"Successfully added the new policy to the password template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Minimum Special Characters\r\nif [[ -n \"$_arg_minimumSpecialCharacters\" ]]; then\r\n  # Extract the current minimum number of special characters from the policy\r\n  currentMinimumSpecial=$(echo \"$currentPolicy\" | grep -w \"minimumSymbols\" | grep -E -o '\\d+')\r\nfi\r\n\r\n# If the current policy already matches the user-provided value, inform the user\r\nif [[ -n \"$_arg_minimumSpecialCharacters\" &amp;&amp; \"$currentMinimumSpecial\" == \"$_arg_minimumSpecialCharacters\" ]]; then\r\n  echo \"The password policy is already set to require a minimum of $_arg_minimumSpecialCharacters special characters.\"\r\n  echo \"\"\r\n\r\n# If the current policy is different, attempt to change it\r\nelif [[ -n \"$_arg_minimumSpecialCharacters\" &amp;&amp; -n \"$currentMinimumSpecial\" ]]; then\r\n  echo \"Attempting to change the password policy from requiring a minimum number of special characters of $currentMinimumSpecial to $_arg_minimumSpecialCharacters.\"\r\n\r\n  # Update the regular expression to enforce the new number of special characters\r\n  if ! sed -i '' \"s\/&lt;string&gt;policyAttributePassword matches '(\\.\\*\\[^a-zA-Z0-9\\]\\.\\*){[0-9]*,}\\+'&lt;\\\/string&gt;\/&lt;string&gt;policyAttributePassword matches '(.*[^a-zA-Z0-9].*){$_arg_minimumSpecialCharacters,}+'&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of special characters password policy.\" 1\r\n  fi\r\n\r\n  # Update the description to reflect the new policy requirement\r\n  if ! sed -i '' \"s\/&lt;string&gt;Must contain at least [0-9]* special character.*&lt;\\\/string&gt;\/&lt;string&gt;Must contain at least $_arg_minimumSpecialCharacters special character(s)&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of special characters password policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder to add the integer value for the new minimum number of special characters\r\n  if ! sed -i '' '\/&lt;key&gt;minimumSymbols&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of special characters password policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual value for the minimum number of special characters\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_minimumSpecialCharacters&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change minimum number of special characters password policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the policy was successfully modified\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no existing policy is found, create and set a new policy for the minimum number of special characters\r\nelif [[ -n \"$_arg_minimumSpecialCharacters\" ]]; then\r\n  echo \"Attempting to set the password policy to require a minimum of $_arg_minimumSpecialCharacters special characters.\"\r\n\r\n  # Define a new policy block with the specified minimum number of special characters\r\n  new_passwordSpecialCharacterPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;policyAttributePassword matches '(.*[^a-zA-Z0-9].*){$_arg_minimumSpecialCharacters,}+'&lt;\\\/string&gt;\r\n    &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Must contain at least $_arg_minimumSpecialCharacters special character(s)&lt;\\\/string&gt;\r\n    &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n    &lt;dict&gt;\r\n        &lt;key&gt;minimumSymbols&lt;\\\/key&gt;\r\n        &lt;integer&gt;$_arg_minimumSpecialCharacters&lt;\\\/integer&gt;\r\n    &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy for insertion into the policy template\r\n  new_passwordSpecialCharacterPolicy=$(echo \"$new_passwordSpecialCharacterPolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new policy block at the appropriate point in the template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordSpecialCharacterPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum special characters policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template for saving\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum special characters policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original template\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new minimum special characters policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new policy was successfully added\r\n  echo \"Successfully added the new policy to the password template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Password History\r\nif [[ -n \"$_arg_passwordHistory\" ]]; then\r\n  # Extract the current password history depth from the policy\r\n  currentPasswordHistory=$(echo \"$currentPolicy\" | grep \"policyAttributePasswordHistoryDepth\" | grep -E -o '\\d+')\r\nfi\r\n\r\n# If the current policy already matches the user-provided value, inform the user\r\nif [[ -n \"$_arg_passwordHistory\" &amp;&amp; \"$currentPasswordHistory\" == \"$_arg_passwordHistory\" ]]; then\r\n  echo \"The password policy is already set to remember the previous $_arg_passwordHistory passwords.\"\r\n  echo \"\"\r\n\r\n# If the current policy is different, attempt to change it\r\nelif [[ -n \"$_arg_passwordHistory\" &amp;&amp; -n \"$currentPasswordHistory\" ]]; then\r\n  echo \"Attempting to change the password policy from remembering the previous $currentPasswordHistory to $_arg_passwordHistory.\"\r\n\r\n  # Update the string describing the number of remembered passwords\r\n  if ! sed -i '' \"s\/&lt;string&gt;Does not match any of last .* passwords&lt;\\\/string&gt;\/&lt;string&gt;Does not match any of last $_arg_passwordHistory passwords&lt;\\\/string&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password history policy.\" 1\r\n  fi\r\n\r\n  # Insert a placeholder to add the integer value for the new password history depth\r\n  if ! sed -i '' '\/&lt;key&gt;policyAttributePasswordHistoryDepth&lt;\\\/key&gt;\/a\\\r\n    &lt;- This integer line will be replaced -&gt;' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password history policy.\" 1\r\n  fi\r\n\r\n  # Replace the placeholder with the actual value for the password history depth\r\n  if ! sed -i '' \"s\/&lt;- This integer line will be replaced -&gt;.*&lt;integer&gt;.*&lt;\\\/integer&gt;\/&lt;integer&gt;$_arg_passwordHistory&lt;\\\/integer&gt;\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to change password history policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the policy was successfully modified\r\n  echo \"Successfully modified the password policy template.\"\r\n  echo \"\"\r\n\r\n# If no existing policy is found, create and set a new policy for password history\r\nelif [[ -n \"$_arg_passwordHistory\" ]]; then\r\n  echo \"Attempting to set the password policy to remember the previous $_arg_passwordHistory passwords.\"\r\n\r\n  # Define a new policy block with the specified password history depth\r\n  new_passwordHistoryPolicy=\"\r\n&lt;dict&gt;\r\n  &lt;key&gt;policyContent&lt;\\\/key&gt;\r\n  &lt;string&gt;none policyAttributePasswordHashes in policyAttributePasswordHistory&lt;\\\/string&gt;\r\n  &lt;key&gt;policyIdentifier&lt;\\\/key&gt;\r\n    &lt;string&gt;Does not match any of the last $_arg_passwordHistory passwords&lt;\\\/string&gt;\r\n  &lt;key&gt;policyParameters&lt;\\\/key&gt;\r\n  &lt;dict&gt;\r\n    &lt;key&gt;policyAttributePasswordHistoryDepth&lt;\\\/key&gt;\r\n    &lt;integer&gt;$_arg_passwordHistory&lt;\\\/integer&gt;\r\n  &lt;\\\/dict&gt;\r\n&lt;\\\/dict&gt;\"\r\n\r\n  # Format the new policy for insertion into the policy template\r\n  new_passwordHistoryPolicy=$(echo \"$new_passwordHistoryPolicy\" | tr '\\n' '`')\r\n\r\n  # Insert the new policy block at the appropriate point in the template\r\n  if ! sed -i '' \"s\/&lt;- PasswordContent line will be replaced -&gt;.*&lt;array&gt;\/&lt;- PasswordContent line will be replaced -&gt;&lt;array&gt;$new_passwordHistoryPolicy\/g\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Convert back the policy template for saving\r\n  if ! tr '`' '\\n' &lt;\"$_policyTemplateFilePath\" &gt;\"$_policyTemplateFilePath2\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Move the new file to replace the original template\r\n  if ! mv -f \"$_policyTemplateFilePath2\" \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add new password history policy.\" 1\r\n  fi\r\n\r\n  # Inform the user that the new policy was successfully added\r\n  echo \"Successfully added the new policy to the password template.\"\r\n  echo \"\"\r\nfi\r\n\r\n# Inform the user that the policy template is being cleaned up\r\necho \"Cleaning up policy template.\"\r\n\r\n# Remove the placeholder for Password Authentication policies from the template\r\nif ! sed -i '' 's\/&lt;- PasswordAuthentication line will be replaced -&gt;\/\/g' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to update the password policy.\" 1\r\nfi\r\n\r\n# Remove the placeholder for Password Content policies from the template\r\nif ! sed -i '' 's\/&lt;- PasswordContent line will be replaced -&gt;\/\/g' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to update the password policy.\" 1\r\nfi\r\n\r\n# Remove the placeholder for Password Change policies from the template\r\nif ! sed -i '' 's\/&lt;- PasswordChange line will be replaced -&gt;\/\/g' \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to update the password policy.\" 1\r\nfi\r\n\r\n# Check if the last two non-empty lines in the file are missing the closing &lt;dict&gt; tag\r\nfinalDict=$(awk 'NF' \"$_policyTemplateFilePath\" | tail -n 2 | grep 'dict')\r\n\r\n# If the &lt;dict&gt; closing tag is missing, add it before the closing &lt;\/plist&gt; tag\r\nif [[ -z \"$finalDict\" ]]; then\r\n  if ! sed -i '' 's\/&lt;\\\/plist&gt;\/&lt;\\\/dict&gt;&lt;\\\/plist&gt;\/g' \"$_policyTemplateFilePath\"; then\r\n    _PRINT_HELP=no die \"[Error] Failed to add closing dict tag to '$_policyTemplateFilePath'.\" 1\r\n  fi\r\nfi\r\n\r\n# Attempt to apply the modified policy template to the system\r\necho \"Attempting to apply the policy template.\"\r\nif ! pwpolicy -setaccountpolicies \"$_policyTemplateFilePath\"; then\r\n  _PRINT_HELP=no die \"[Error] Failed to update the password policy.\" 1\r\nelse\r\n  echo \"Successfully applied the policy template.\"\r\nfi\r\n\r\n# Clean up by removing the temporary policy template file\r\necho \"Removing temporary policy template file.\"\r\nif [[ -f \"$_policyTemplateFilePath\" ]]; then\r\n  rm \"$_policyTemplateFilePath\"\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Ce script shell vous permet de personnaliser ou de r\u00e9initialiser la politique de mot de passe de macOS \u00e0 l&rsquo;aide d&rsquo;une s\u00e9rie de param\u00e8tres, y compris :<\/p>\n<ul>\n<li>Nombre maximal de tentatives de connexion<\/li>\n<li>Dur\u00e9e du verrouillage<\/li>\n<li>Expiration du mot de passe<\/li>\n<li>Exigences de complexit\u00e9 (longueur, majuscules, minuscules, caract\u00e8res num\u00e9riques, caract\u00e8res sp\u00e9ciaux)<\/li>\n<li>Taille de l&rsquo;historique des mots de passe<\/li>\n<li>R\u00e9tablissement de la politique Apple par d\u00e9faut<\/li>\n<\/ul>\n<h3>Analyse et validation des arguments<\/h3>\n<p>Le script commence par d\u00e9finir les arguments attendus et fournit une interface d&rsquo;aide robuste. Il prend en charge les drapeaux d&rsquo;argument de forme longue et abr\u00e9g\u00e9e (par exemple, &#8211;maxLoginAttempts et -a) et inclut une validation compl\u00e8te pour s&rsquo;assurer que les valeurs sont num\u00e9riques et logiquement valides (par exemple, la longueur du mot de passe doit \u00eatre \u2265 8).<\/p>\n<h3>Processus d&rsquo;application des politiques<\/h3>\n<p>La logique de base suit les \u00e9tapes suivantes :<\/p>\n<ol>\n<li><strong>V\u00e9rifier les privil\u00e8ges de l&rsquo;administrateur<\/strong>\u00a0&#8211; Les commandes pwpolicy requi\u00e8rent un acc\u00e8s administratif.<\/li>\n<li><strong>Rejeter les entr\u00e9es conflictuelles<\/strong>\u00a0&#8211; Vous ne pouvez pas d\u00e9finir une politique personnalis\u00e9e et r\u00e9tablir la valeur par d\u00e9faut dans la m\u00eame ex\u00e9cution.<\/li>\n<li><strong>Lire et modifier le mod\u00e8le Plist<\/strong>\u00a0&#8211; Le script r\u00e9cup\u00e8re les politiques actuelles dans un fichier XML .plist. Si le fichier ne contient pas les cat\u00e9gories requises (Authentication, PasswordContent, PasswordChange), il les ins\u00e8re.<\/li>\n<li><strong>Insertion de politique<\/strong>\u00a0&#8211; En fonction des entr\u00e9es de l&rsquo;utilisateur, il injecte ou modifie les blocs XML &lt;dict&gt; appropri\u00e9s dans la liste .plist, en utilisant sed, awk et tr pour une manipulation s\u00fbre du texte.<\/li>\n<li><strong>Appliquer la politique<\/strong>\u00a0&#8211; Le fichier .plist modifi\u00e9 est appliqu\u00e9 \u00e0 l&rsquo;ensemble du syst\u00e8me \u00e0 l&rsquo;aide de pwpolicy -setaccountpolicies.<\/li>\n<li><strong>Nettoyage<\/strong>\u00a0&#8211; Les fichiers temporaires sont supprim\u00e9s pour maintenir la propret\u00e9 et la s\u00e9curit\u00e9.<\/li>\n<\/ol>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p>Cas de figure\u00a0: Un MSP accueille un nouveau client<\/p>\n<p>Un fournisseur de services g\u00e9r\u00e9s (MSP) est en train d&rsquo;int\u00e9grer un nouveau client avec 120 terminaux macOS. Le client souhaite mettre en \u0153uvre les \u00e9l\u00e9ments suivants :<\/p>\n<ul>\n<li>3 tentatives de connexion \u00e9chou\u00e9es avant le verrouillage<\/li>\n<li>Dur\u00e9e de verrouillage de 15 minutes<\/li>\n<li>Les mots de passe doivent comporter plus de 12 caract\u00e8res, dont au moins 1 majuscule, 1 minuscule, 1 chiffre et 1 caract\u00e8re sp\u00e9cial<\/li>\n<li>Les mots de passe expirent tous les 90 jours<\/li>\n<li>La r\u00e9utilisation des 5 derniers mots de passe est interdite<\/li>\n<\/ul>\n<p>Plut\u00f4t que de les d\u00e9finir manuellement sur chaque appareil ou d&rsquo;\u00e9crire des profils de configuration MDM fragiles, le MSP utilise ce script dans le module de script de NinjaOne, en ciblant tous les terminaux. Le processus se d\u00e9roule en quelques minutes et garantit la conformit\u00e9 d\u00e8s le premier jour.<\/p>\n<h2>Comparaisons<\/h2>\n<h3>Configuration manuelle via les pr\u00e9f\u00e9rences du syst\u00e8me<\/h3>\n<ul>\n<li>Options limit\u00e9es<\/li>\n<li>Pas de prise en charge des contraintes avanc\u00e9es telles que l&rsquo;historique des mots de passe<\/li>\n<\/ul>\n<h3>Profils de configuration MDM<\/h3>\n<ul>\n<li>Souvent complexe et difficile \u00e0 d\u00e9panner<\/li>\n<li>Pas toujours pr\u00e9cis ou compatible avec les diff\u00e9rentes versions du syst\u00e8me d&rsquo;exploitation<\/li>\n<\/ul>\n<h3>Ce script Shell<\/h3>\n<ul>\n<li>Offre un contr\u00f4le total via pwpolicy<\/li>\n<li>Facilement versionnable et actualisable<\/li>\n<li>S&rsquo;int\u00e8gre parfaitement aux outils de gestion \u00e0 distance tels que NinjaOne<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<h3>Q\u00a0: Ce script est-il compatible avec toutes les versions de macOS ?<\/h3>\n<p>R\u00a0: Le script est compatible avec les versions de macOS qui prennent en charge pwpolicy, ce qui inclut macOS 10.7 et les versions plus r\u00e9centes.<\/p>\n<h3>Q\u00a0: Puis-je utiliser ce script avec le MDM ?<\/h3>\n<p>R\u00a0: Vous pouvez le faire, mais il est plus efficace lorsqu&rsquo;il est ex\u00e9cut\u00e9 via des syst\u00e8mes de RMM ou des syst\u00e8mes de gestion des terminaux comme NinjaOne, o\u00f9 l&rsquo;acc\u00e8s root est disponible.<\/p>\n<h3>Q\u00a0: Que se passe-t-il si des param\u00e8tres contradictoires sont transmis (par exemple, une politique personnalis\u00e9e et un drapeau de r\u00e9initialisation) ?<\/h3>\n<p>R\u00a0: Le script interrompt l&rsquo;ex\u00e9cution et affiche une erreur afin d&rsquo;\u00e9viter toute mauvaise configuration accidentelle.<\/p>\n<h2>Implications<\/h2>\n<p>L&rsquo;application de politiques de mots de passe forts sur les appareils macOS r\u00e9duit le risque d&rsquo;attaques par force brute, de bourrage d&rsquo;informations d&rsquo;identification et d&rsquo;acc\u00e8s non autoris\u00e9. Toutefois, des r\u00e8gles trop strictes peuvent entra\u00eener la frustration des utilisateurs ou une augmentation des tickets d&rsquo;assistance. La flexibilit\u00e9 de ce script permet de trouver un juste \u00e9quilibre entre s\u00e9curit\u00e9 et facilit\u00e9 d&rsquo;utilisation.<\/p>\n<p>De plus, la nature centralis\u00e9e et automatis\u00e9e du script <a href=\"https:\/\/www.ninjaone.com\/fr\/blog\/le-lien-entre-lerreur-humaine-et-les-risques-de-cybersecurite\/\">r\u00e9duit les erreurs humaines<\/a> et garantit une posture de s\u00e9curit\u00e9 coh\u00e9rente pour tous les appareils g\u00e9r\u00e9s.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li><strong>Testez toujours la politique sur un seul appareil<\/strong>\u00a0avant de la d\u00e9ployer \u00e0 grande \u00e9chelle afin de vous assurer qu&rsquo;elle se comporte comme pr\u00e9vu.<\/li>\n<li><strong>Utilisez le planificateur de scripts de NinjaOne<\/strong>\u00a0pour effectuer des contr\u00f4les r\u00e9currents et r\u00e9appliquer le logiciel si n\u00e9cessaire.<\/li>\n<li><strong>Le contr\u00f4le des versions<\/strong>\u00a0permet de suivre les modifications apport\u00e9es \u00e0 votre script au fil du temps et d&rsquo;en assurer l&rsquo;auditabilit\u00e9.<\/li>\n<li><strong>Combinez avec les outils de journalisation<\/strong>\u00a0pour surveiller les tentatives de connexion infructueuses ou les verrouillages en temps r\u00e9el.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Pour les professionnels de l&rsquo;informatique et les MSP qui g\u00e8rent des environnements macOS, la d\u00e9finition de politiques de mot de passe doit \u00eatre claire et pr\u00e9cise. Ce script apporte pr\u00e9cision, <a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/automatisation-informatique\/\">automatisation<\/a> et clart\u00e9 \u00e0 l&rsquo;application de la politique des mots de passe. Associ\u00e9 aux capacit\u00e9s centralis\u00e9es de script et d&rsquo;automatisation de <a href=\"https:\/\/www.ninjaone.fr\/\" target=\"_blank\" rel=\"noopener\">NinjaOne<\/a>, il devient un outil puissant pour s\u00e9curiser les appareils macOS \u00e0 grande \u00e9chelle.<\/p>\n<p>Que vous preniez en charge 10 terminaux ou 10 000, ce script vous permet d&rsquo;appliquer les normes de s\u00e9curit\u00e9 de mani\u00e8re rapide et fiable, une politique \u00e0 la fois.<\/p>\n","protected":false},"author":35,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4210],"use_cases":[4281],"class_list":["post-513831","script_hub","type-script_hub","status-publish","hentry","script_hub_category-macos"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/513831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/comments?post=513831"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=513831"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=513831"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=513831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}