{"id":310249,"date":"2024-07-23T15:07:30","date_gmt":"2024-07-23T15:07:30","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=310249"},"modified":"2024-07-23T15:07:30","modified_gmt":"2024-07-23T15:07:30","slug":"fenetres-contextuelles-de-messages-pop-up-personnalises-sur-macos","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/fr\/script-hub\/fenetres-contextuelles-de-messages-pop-up-personnalises-sur-macos\/","title":{"rendered":"Guide complet des fen\u00eatres contextuelles de messages pop-up personnalis\u00e9s sur macOS"},"content":{"rendered":"<h2>Points \u00e0 retenir<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Le script cr\u00e9e des fen\u00eatres contextuelles ou pop-up personnalis\u00e9s sur macOS, am\u00e9liorant ainsi la communication directe entre les professionnels de l&rsquo;informatique et les utilisateurs finaux.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Il offre des options de personnalisation \u00e9tendues pour le titre du pop-up, le message, les boutons, les ic\u00f4nes et les actions.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Les utilisateurs peuvent d\u00e9finir des actions sp\u00e9cifiques \u00e0 ex\u00e9cuter lorsqu&rsquo;ils appuient sur un bouton ou lorsque la fen\u00eatre contextuelle expire, ce qui facilite l&rsquo;automatisation des t\u00e2ches de gestion informatique.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\">Le script comprend des contr\u00f4les d&rsquo;erreur pour les erreurs de configuration courantes, ce qui garantit un fonctionnement fiable et s\u00fbr.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\">Par rapport aux m\u00e9thodes traditionnelles telles que les e-mails, ce script offre un moyen plus rapide et interactif de transmettre des messages.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"6\" data-aria-level=\"1\">Son utilisation \u00e9thique et la transparence sont essentielles, compte tenu de la capacit\u00e9 du script \u00e0 susciter des actions directes de la part de l&rsquo;utilisateur.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"7\" data-aria-level=\"1\">Des tests approfondis et une communication claire avec les utilisateurs sont recommand\u00e9s pour un d\u00e9ploiement efficace.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"8\" data-aria-level=\"1\">Ce script compl\u00e8te des outils tels que NinjaOne, en am\u00e9liorant l&rsquo;efficacit\u00e9 et le contr\u00f4le de la gestion informatique.<\/li>\n<\/ul>\n<h2>Introduction<\/h2>\n<p>La capacit\u00e9 \u00e0 communiquer et \u00e0 g\u00e9rer efficacement les actions des utilisateurs est un aspect crucial de la <a href=\"https:\/\/www.ninjaone.com\/fr\/gestion-informatique-grande-entreprise\/infrastructure\/\">gestion de l&rsquo;infrastructure informatique<\/a>. Un script permettant de cr\u00e9er des messages contextuels ou pop-ups personnalisables sur les appareils macOS illustre cette n\u00e9cessit\u00e9 et constitue un outil polyvalent pour les administrateurs syst\u00e8me et les <a href=\"https:\/\/www.ninjaone.com\/fr\/quest-ce-quun-msp\">fournisseurs de services g\u00e9r\u00e9s (MSP).\u00a0<\/a><\/p>\n<h2>Contexte<\/h2>\n<p>La fonction principale de ce script Bash est de g\u00e9n\u00e9rer des messages pop-up personnalisables sur macOS, en offrant une vari\u00e9t\u00e9 de param\u00e8tres pour la personnalisation. Cette capacit\u00e9 est particuli\u00e8rement utile pour les professionnels de l&rsquo;informatique et les MSP qui ont besoin de d\u00e9clencher des actions ou de transmettre des informations directement aux utilisateurs finaux d&rsquo;une mani\u00e8re contr\u00f4l\u00e9e et efficace. Il est utile car il r\u00e9pond \u00e0 la n\u00e9cessit\u00e9 d&rsquo;am\u00e9liorer la communication d&rsquo;une mani\u00e8re non intrusive mais directe.<\/p>\n<h2>Le script :<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">#!\/usr\/bin\/env bash\r\n#\r\n# Description: Creates a popup window on the user's screen. Use Restart Reminder to display a request to the end user to restart their computer. Please run as 'System'.\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: --restartreminder\r\n#   Displays a generic restart PopUp. Can be overridden with parameters. Equivalent to the below parameters.\r\n#   --title 'NinjaOne Rmm'\r\n#   --message 'Your IT Administrator is requesting that you restart your computer. Click \"Restart Now\" after saving your work.'\r\n#   --buttonltext 'Restart Now'\r\n#   --buttonrtext 'Ignore'\r\n#   --buttonlaction 'shutdown -r now'\r\n#   --timeout 900\r\n#\r\n# Preset Parameter: --title 'ReplaceWithYourDesiredHeader'\r\n#   Replace the text encased in quotes to replace the text in the title bar of the popup window (defaults to 'NinjaOne RMM').\r\n#\r\n# Preset Parameter: --message 'ReplaceWithYourPopUpMessage'\r\n#   Replace the text encased in quotes to put some text inside of the PopUp Window.\r\n#\r\n# Preset Parameter: --iconpath 'A URL or \/a\/path\/to\/an\/image.png'\r\n#   Replace the text encased in quotes with either a url to an image or a filepath to an icon. The script uses the NinjaOne Logo by default.\r\n#   For best results use a 512px x 512px png. Though other formats and sizes will work.\r\n#   Highly recommend keeping a 1:1 ratio for the width and height.\r\n#   Supported formats: png, jpg, jpeg, webp, bmp, ico and gif (will not be animated in popup)\r\n#   If you have a base64 encoding of your image you could also replace the default base64 on line 46.\r\n#\r\n# Preset Parameter: --buttonltext 'ReplaceWithNameOfButton'\r\n#   Replace the text encased in quotes with the name\/text inside the left button.\r\n#\r\n# Preset Parameter: --buttonrtext 'ReplaceWithNameOfButton'\r\n#   Replace the text encased in quotes with the name\/text inside the right button.\r\n#\r\n# Preset Parameter: --timeout 'ReplaceWithAnumberofSeconds'\r\n#   Replace the text encased in quotes with the number of seconds you'd like the PopUp to display for. 0 never times out.\r\n#\r\n# Preset Parameter: --buttonlaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the left button is clicked by the user (executes in bash).\r\n#\r\n# Preset Parameter: --buttonraction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the right button is clicked by the user (executes in bash).\r\n#\r\n# Preset Parameter: --timeoutaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\r\n#   Replace the text encased in quotes with the command you'd like to run when the dialog box times out (executes in bash).\r\n\r\n# You can replace the below line with iconbase64='ReplaceThisWithYourBase64encodedimageEncasedInQuotes' and the script will decode the image and use it in the popup window.\r\niconbase64='iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAJFBMVEUARF0Apc0AmL8ApM0Aos0Aps7\/\/\/8Am8ia1ug9rtLd8\/jw+\/2tMDHwAAAABXRSTlMBrBTIcce4nvwAAAIeSURBVHic7dvrcoMgEAXgiOAivv\/7Fm+JBpCLwk7bsz86rcNkPw+Y0Gl5vd4lGtbLKSG7vmF18mwQnWpe3YcghP2Z1svU8OtbIOihm8op25M2gWBov9UqYJj\/vSRzAGsEkhMglxngWINbdbxLAAAAAAAAAAAAAKAI8Oz2KRtApPWThEyAbT8NZwDZGpeav6sLIKXNMBwAtuGotTGTvTpMRms9qkxEBsDe\/dz+A7B3rufeS\/utrCKPkAywzfYmK8BeOHY+lBkzBImALfwDgA4XnNLphCTA4e43AKmL9vNMJD8pCQAna20nP5D+SfkQgJyp1qS9PYsEKQDnpVP627WYJCgBmGj+GRmUAFIraSXWBAwDcwJJk1AXMIzcgHgElQHxCGoDohHcBsybgIvPpei70S2A0csuaNkTBRBTbA7uAOb271E0+gWxOSgHfG87yD+wGsCz7fGONNf9iwGTb89DnlkwkUVQCPD2t1sXz9A6gMDT5YsgsggKARljI\/vTMkDo7cU3B1USCL+oOwdVAMGF5RlcAxB+tBoBwq\/JDlDcAPYEAGgDuPiNBwkgASSABJAAEkACSAAJIAEkgASQABL4JwlcA9w\/9N4GTOZcl1OQMTgRoEannhv9O\/+PCAAAAAAAAAAAAACAPwhgP+7HeOCR1jOfjBHI9dBrz9W\/34\/d9jyHLvvPweP2GdCx\/3zyvLlAfZ8+l13LktJzAJ+nfgAP50EVLvPsRgAAAABJRU5ErkJggg=='\r\nworkingdir=\"\/tmp\/ninjaone-rmm-popup\"\r\n\r\ndie() {\r\n  local _ret=\"${2:-1}\"\r\n  test \"${_PRINT_HELP:-no}\" = yes &amp;&amp; print_help &gt;&amp;2\r\n  echo \"$1\" &gt;&amp;2\r\n  exit \"${_ret}\"\r\n}\r\n\r\n# THE DEFAULTS INITIALIZATION - OPTIONALS\r\n_arg_title=\"NinjaOne RMM\"\r\n_arg_message=\r\n_arg_iconpath=\r\n_arg_buttonrtext=\r\n_arg_buttonraction=\r\n_arg_buttonltext=\r\n_arg_buttonlaction=\r\n_arg_timeoutaction=\r\n_arg_timeout=900\r\n_arg_restartreminder=\"off\"\r\n\r\n# This function will print out some help text if the user entered something wrong\r\nprint_help() {\r\n  printf '\\t%s\\n\\n' 'Usage: [-t|--title &lt;arg&gt;] [-m|-msg|--message &lt;arg&gt;] [-i|-icon|--iconpath &lt;arg&gt;] [-blt|-btnltxt|--buttonltext &lt;arg&gt;] [-brt|-btnrtxt|--buttonrtext &lt;arg&gt;] [-bla|-btnlact|--buttonlaction &lt;arg&gt;] [-bra|-btnract|--buttonraction &lt;arg&gt;] [-to|--timeout &lt;arg&gt;] [-toa|-toact|--timeoutaction &lt;arg&gt;] [-restart|--restartreminder] [-h|--help]'\r\n  printf '\\t%s\\n' \"Preset Parameter: --restartreminder\"\r\n  printf '\\t\\t%s\\n' \"Displays a generic restart PopUp. Can be overridden with parameters. Equivalent to the below parameters.\"\r\n  printf '\\t\\t%s\\n' \"--title 'NinjaOne RMM'\"\r\n  printf '\\t\\t%s\\n' \"--message 'Your IT Administrator is requesting that you restart your computer. Click 'Restart Now' after saving your work.'\"\r\n  printf '\\t\\t%s\\n' \"--buttonltext 'Restart Now'\"\r\n  printf '\\t\\t%s\\n' \"--buttonrtext 'Ignore'\"\r\n  printf '\\t\\t%s\\n' \"--buttonlaction 'shutdown -r now'\"\r\n  printf '\\t\\t%s\\n' \"--timeout '900'\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --title 'ReplaceWithYourDesiredHeader'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes to replace the text in the title bar of the popup window (defaults to 'NinjaOne RMM')\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --message 'ReplaceWithYourPopUpMessage'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes to put some text inside of the PopUp Window\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --iconpath 'A URL or \/a\/path\/to\/an\/image.png'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with either a url to an image or a filepath to an icon. The script uses the NinjaOne Logo by default.\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --buttonltext 'ReplaceWithNameOfButton'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the name\/text inside the left button.\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --buttonrtext 'ReplaceWithNameOfButton'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the name\/text inside the right button.\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --timeout 'ReplaceWithAnumberofSeconds'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the number of seconds you'd like the PopUp to display for. 0 never times out.\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --buttonlaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the left button is clicked by the user (executes in bash).\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --buttonraction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the right button is clicked by the user (executes in bash).\"\r\n  printf '\\t%s\\n' \"Preset Parameter: --timeoutaction 'ReplaceWithYourDesiredAction(Executes in Bash)'\"\r\n  printf '\\t\\t%s\\n' \"Replace the text encased in quotes with the command you'd like to run when the dialog box times out (executes in bash).\"\r\n}\r\n\r\n# Deciphers the parameters given and stores them as variables\r\nparse_commandline() {\r\n  while test $# -gt 0; do\r\n    _key=\"$1\"\r\n    case \"$_key\" in\r\n    -t | --title)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_title=\"$2\"\r\n      shift\r\n      ;;\r\n    --title=*)\r\n      _arg_title=\"${_key##--title=}\"\r\n      ;;\r\n    -m | -msg | --message)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_message=\"$2\"\r\n      shift\r\n      ;;\r\n    --message=*)\r\n      _arg_message=\"${_key##--message=}\"\r\n      ;;\r\n    --msg=*)\r\n      _arg_message=\"${_key##--msg=}\"\r\n      ;;\r\n    -i | -icon | --iconpath)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_iconpath=\"$2\"\r\n      shift\r\n      ;;\r\n    --iconpath=*)\r\n      _arg_iconpath=\"${_key##--iconpath=}\"\r\n      ;;\r\n    --icon=*)\r\n      _arg_iconpath=\"${_key##--icon=}\"\r\n      ;;\r\n    -blt | -btnltxt | --buttonltext)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_buttonltext=\"$2\"\r\n      shift\r\n      ;;\r\n    --buttonltext=*)\r\n      _arg_buttonltext=\"${_key##--buttonltext=}\"\r\n      ;;\r\n    -bla | -btnlact | -btnlaction | --buttonlaction)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_buttonlaction=\"$2\"\r\n      shift\r\n      ;;\r\n    --buttonlaction=*)\r\n      _arg_buttonlaction=\"${_key##--buttonlaction=}\"\r\n      ;;\r\n    -brt | -btnrtxt | -btnrtext | --buttonrtext)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_buttonrtext=\"$2\"\r\n      shift\r\n      ;;\r\n    --buttonrtext=*)\r\n      _arg_buttonrtext=\"${_key##--buttonrtext=}\"\r\n      ;;\r\n    -bra | -btnract | -btnraction | --buttonraction)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_buttonraction=\"$2\"\r\n      shift\r\n      ;;\r\n    --buttonraction=*)\r\n      _arg_buttonraction=\"${_key##--buttonraction=}\"\r\n      ;;\r\n    -to | --timeout)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_timeout=\"$2\"\r\n      shift\r\n      ;;\r\n    --timeout=*)\r\n      _arg_timeout=\"${_key##--timeout=}\"\r\n      ;;\r\n    -toa | -toact | --timeoutaction | --timeoutAction)\r\n      test $# -lt 2 &amp;&amp; die \"Missing value for the optional argument '$_key'.\" 1\r\n      _arg_timeoutaction=\"$2\"\r\n      shift\r\n      ;;\r\n    --timeoutaction=*)\r\n      _arg_timeoutaction=\"${_key##--timeoutaction=}\"\r\n      ;;\r\n    -restart | --restartreminder | --restartReminder)\r\n      _arg_restartreminder=\"on\"\r\n      ;;\r\n    -h | --help)\r\n      print_help\r\n      exit 0\r\n      ;;\r\n    -h*)\r\n      print_help\r\n      exit 0\r\n      ;;\r\n    *)\r\n      _PRINT_HELP=yes die \"FATAL ERROR: Got an unexpected argument '$1'\" 1\r\n      ;;\r\n    esac\r\n    shift\r\n  done\r\n}\r\n\r\nparse_commandline \"$@\"\r\n\r\n# This function will be used to download an image file if requested.\r\ndownloadFile() {\r\n  i=1\r\n  while [[ $i -lt 4 ]]; do\r\n    if [[ ! $_arg_skipsleep == \"on\" ]]; then\r\n      sleepTime=$((1 + RANDOM % 7))\r\n      echo \"Sleeping for $sleepTime seconds.\"\r\n      sleep $sleepTime\r\n    fi\r\n\r\n    echo \"Download Attempt $i\"\r\n    curl -L \"$url\" -o \"$_arg_destfolder\/$_arg_filename\" -s -f\r\n\r\n    file=$_arg_destfolder\/$_arg_filename\r\n    if [[ -f $file ]]; then\r\n      echo 'Download was successful!'\r\n      i=4\r\n    else\r\n      echo 'Attempt Failed!'\r\n      ((i += 1))\r\n    fi\r\n  done\r\n}\r\n\r\nif [[ -n $title ]]; then\r\n  _arg_title=$title\r\nfi\r\n\r\nif [[ -n $message ]]; then\r\n  _arg_message=$message\r\nfi\r\n\r\nif [[ -n $iconPath ]]; then\r\n  _arg_iconpath=$iconPath\r\nfi\r\n\r\nif [[ -n $buttonLeftText ]]; then\r\n  _arg_buttonltext=$buttonLeftText\r\nfi\r\n\r\nif [[ -n $buttonLeftAction ]]; then\r\n  _arg_buttonlaction=$buttonLeftAction\r\nfi\r\n\r\nif [[ -n $buttonRightText ]]; then\r\n  _arg_buttonrtext=$buttonRightText\r\nfi\r\n\r\nif [[ -n $buttonRightAction ]]; then\r\n  _arg_buttonraction=$buttonRightAction\r\nfi\r\n\r\nif [[ -n $timeout ]]; then\r\n  _arg_timeout=$timeout\r\nfi\r\n\r\nif [[ -n $timeoutAction ]]; then\r\n  _arg_timeoutaction=$timeoutAction\r\nfi\r\n\r\nif [[ -n $restartReminder &amp;&amp; $restartReminder == \"true\" ]]; then\r\n  _arg_restartreminder=\"on\"\r\nfi\r\n\r\n# If --restartreminder was selected we'll want to preset some of the parameters.\r\nif [[ $_arg_restartreminder == \"on\" ]]; then\r\n  if [[ -z $_arg_buttonltext ]]; then\r\n    _arg_buttonltext=\"Restart Now\"\r\n  fi\r\n\r\n  if [[ -z $_arg_buttonrtext ]]; then\r\n    _arg_buttonrtext=\"Ignore\"\r\n  fi\r\n\r\n  if [[ -z $_arg_message ]]; then\r\n    _arg_message=\"Your IT Administrator is requesting that you restart your computer. Click 'Restart Now' after saving your work.\"\r\n  fi\r\n\r\n  if [[ -z $_arg_buttonlaction ]]; then\r\n    _arg_buttonlaction='shutdown -r $(date -v +30S \"+%H%M\")'\r\n  fi\r\n\r\n  if [[ -z $_arg_timeout ]]; then\r\n    _arg_timeout=900\r\n  fi\r\nfi\r\n\r\n# Cannot name the button cancel.\r\nif [[ $_arg_buttonltext == \"Cancel\" || $_arg_buttonrtext == \"Cancel\" ]]; then\r\n  _PRINT_HELP=no die \"FATAL ERROR: Cannot name the button 'Cancel' or we'll be unable to check the dialog response.\" 1\r\nfi\r\n\r\n# Must give a number\r\npattern='^[0-9]+$'\r\nif [[ ! $_arg_timeout =~ $pattern ]]; then\r\n  _PRINT_HELP=no die \"FATAL ERROR: --timeout requires a number of seconds in order to work. ex. '60' for 60 seconds.\" 1\r\nfi\r\n\r\n# Creates a working directory that we'll use for our icons\r\nif [[ ! -d \"$workingdir\" ]]; then\r\n  mkdir $workingdir\r\nfi\r\n\r\n# If we were given a url we'll want to download it. Since we don't really know the file we'll just not give it an extension.\r\npattern='^http(.?):\/\/(.*)'\r\nif [[ $_arg_iconpath =~ $pattern ]]; then\r\n  echo \"URL Given, downloading image...\"\r\n\r\n  url=$_arg_iconpath\r\n  _arg_destfolder=$workingdir\r\n  _arg_filename=\"downloadedimg\"\r\n\r\n  downloadFile\r\n  _arg_iconpath=$workingdir\/downloadedimg\r\nfi\r\n\r\n# If the script was given an iconpath as a parameter we'll want to use that instead.\r\nif [[ -n $iconbase64 &amp;&amp; -z $_arg_iconpath ]]; then\r\n  base64 -D &lt;&lt;&lt;$iconbase64 &gt;$workingdir\/base64img\r\n  _arg_iconpath=$workingdir\/base64img\r\nelif [[ ! $_arg_iconpath == \"$workingdir\/downloadedimg\" ]]; then\r\n  cp \"$_arg_iconpath\" \"$workingdir\"\r\nfi\r\n\r\n# This will be used to check that the file is an image or something else\r\nmimetype=$(file --mime-type -b \"$_arg_iconpath\" | grep \"image\" | sed 's\/image\\\/\/\/g')\r\nif [[ -z $mimetype ]]; then\r\n  _PRINT_HELP=no die \"FATAL ERROR: File was either not an image or does not exist!\" 1\r\nfi\r\n\r\n# Convert whatever we were given into a png (so we can later turn that into an icon file)\r\nif [[ ! $mimetype == \"png\" ]]; then\r\n  sips -s format png \"$_arg_iconpath\" --out \"$workingdir\/img.png\" &gt;\/dev\/null\r\n  rm \"$_arg_iconpath\"\r\nelse\r\n  mv \"$_arg_iconpath\" \"$workingdir\/img.png\"\r\nfi\r\n\r\n# Working folder for the iconset\r\nif [[ ! -d \"$workingdir\/$_arg_title.iconset\" ]]; then\r\n  mkdir \"$workingdir\/$_arg_title.iconset\"\r\nfi\r\n\r\n# If the file was successfully converted we'll turn it into an icon file\r\nfile=$workingdir\/img.png\r\nif [[ -f $file ]]; then\r\n  sips -z 16 16 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_16x16.png\" &gt;\/dev\/null\r\n  sips -z 32 32 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_16x16@2x.png\" &gt;\/dev\/null\r\n  sips -z 32 32 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_32x32.png\" &gt;\/dev\/null\r\n  sips -z 64 64 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_32x32@2x.png\" &gt;\/dev\/null\r\n  sips -z 128 128 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_128x128.png\" &gt;\/dev\/null\r\n  sips -z 256 256 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_128x128@2x.png\" &gt;\/dev\/null\r\n  sips -z 256 256 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_256x256.png\" &gt;\/dev\/null\r\n  sips -z 512 512 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_256x256@2x.png\" &gt;\/dev\/null\r\n  sips -z 512 512 \"${workingdir}\/img.png\" --out \"${workingdir}\/${_arg_title}.iconset\/icon_512x512.png\" &gt;\/dev\/null\r\n\r\n  rm \"$workingdir\/img.png\"\r\n\r\n  cd \"$workingdir\" &gt;\/dev\/null || _PRINT_HELP=no die \"FATAL ERROR: Unable to access $workingdir\" 1\r\n  iconutil -c icns \"$_arg_title.iconset\"\r\n  cd - &gt;\/dev\/null || _PRINT_HELP=no die \"FATAL ERROR: Unable to access previous working directory?\" 1\r\n\r\n  rm -R \"$workingdir\/$_arg_title.iconset\"\r\n  _arg_iconpath=$workingdir\/$_arg_title.icns\r\nelse\r\n  _PRINT_HELP=no die \"FATAL ERROR: Looks like the image failed to convert to a png?\" 1\r\nfi\r\n\r\n# If no button text was given these will be the defaults\r\nif [[ -z $_arg_buttonltext ]]; then\r\n  _arg_buttonltext=\"Ignore\"\r\nfi\r\n\r\nif [[ -z $_arg_buttonrtext ]]; then\r\n  _arg_buttonrtext=\"Accept\"\r\nfi\r\n\r\n# osascript actually creates the dialog box we'll need all the variables from earlier for that.\r\ndialog=\"$(\r\n  osascript - \"$_arg_message\" \"$_arg_title\" \"$_arg_iconpath\" \"$_arg_buttonltext\" \"$_arg_buttonrtext\" \"$_arg_timeout\" &lt;&lt;EOF\r\n  on run argv\r\n    display dialog item 1 of argv with title item 2 of argv \\\r\n    with icon POSIX file { item 3 of argv } \\\r\n    buttons { item 4 of argv , item 5 of argv } default button 2 \\\r\n    giving up after { item 6 of argv }\r\n  end run\r\nEOF\r\n)\"\r\n\r\n# These three if statements check what the response to the PopUp was and performs an action based on that if requested.\r\nif [[ $dialog == *\"gave up:true\" ]]; then\r\n  echo \"PopUp message timed out (the user ignored it).\"\r\n  if [[ -n $_arg_timeoutaction ]]; then\r\n    eval \"$_arg_timeoutaction\"\r\n  fi\r\n  exit 0\r\nfi\r\n\r\nif [[ $dialog == \"button returned:$_arg_buttonltext\"* ]]; then\r\n  echo \"$_arg_buttonltext Button Clicked!\"\r\n  if [[ -n $_arg_buttonlaction ]]; then\r\n    eval \"$_arg_buttonlaction\"\r\n  fi\r\n  exit 0\r\nfi\r\n\r\nif [[ $dialog == \"button returned:$_arg_buttonrtext\"* ]]; then\r\n  echo \"$_arg_buttonrtext Button Clicked!\"\r\n  if [[ -n $_arg_buttonraction ]]; then\r\n    eval \"$_arg_buttonraction\"\r\n  fi\r\n  exit 0\r\nfi\r\n\r\n_PRINT_HELP=no die \"FATAL ERROR: Did the PopUp display? Failed to check the dialog response.\" 1<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acc\u00e9dez \u00e0 plus de 700 scripts dans le Dojo NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obtenir l&rsquo;acc\u00e8s<\/a><\/p>\n<\/div>\n<h2>Description d\u00e9taill\u00e9e<\/h2>\n<p>Le script commence par initialiser les valeurs par d\u00e9faut et analyse les arguments de la ligne de commande pour personnaliser divers \u00e9l\u00e9ments du pop-up, tels que le titre, le message, les boutons et les actions associ\u00e9es \u00e0 ces boutons. Les param\u00e8tres permettent de personnaliser l&rsquo;apparence et le comportement de la fen\u00eatre contextuelle, comme la d\u00e9finition d&rsquo;une ic\u00f4ne, la dur\u00e9e du d\u00e9lai d&rsquo;attente et les actions \u00e0 ex\u00e9cuter en cas de pression sur un bouton ou de d\u00e9lai d&rsquo;attente.<\/p>\n<p>L&rsquo;une des fonctions du script consiste \u00e0 t\u00e9l\u00e9charger et \u00e0 d\u00e9finir une ic\u00f4ne personnalis\u00e9e pour le pop-up, ce qui illustre sa polyvalence. De plus, il g\u00e8re diff\u00e9rents sc\u00e9narios, comme le fait qu&rsquo;un utilisateur ignore la fen\u00eatre contextuelle ou appuie sur l&rsquo;un des boutons, chacun d\u00e9clenchant des actions sp\u00e9cifiques.<\/p>\n<p>Le script est fiable, avec des contr\u00f4les pour les erreurs telles qu&rsquo;un nom de bouton incorrect ou des valeurs de d\u00e9lai d&rsquo;attente non valides. Ces garanties assurent une ex\u00e9cution sans probl\u00e8mes et \u00e9vitent les erreurs courantes lors de la configuration.<\/p>\n<h2>Cas d&rsquo;utilisation potentiels<\/h2>\n<p>Un professionnel de l&rsquo;informatique dans une entreprise pourrait utiliser ce script pour rappeler aux employ\u00e9s de red\u00e9marrer leur ordinateur pour les mises \u00e0 jour logicielles. La capacit\u00e9 du script \u00e0 planifier les red\u00e9marrages et \u00e0 fournir des options permettant de les reporter ou de les lancer imm\u00e9diatement en fait un outil id\u00e9al pour maintenir un environnement informatique actualis\u00e9 et s\u00e9curis\u00e9.<\/p>\n<h2>Comparaisons<\/h2>\n<p>Traditionnellement, les services informatiques s&rsquo;appuient sur des notifications par e-mail ou des interventions manuelles pour ce type de t\u00e2ches. Ce script offre une approche plus directe et plus conviviale, permettant une interaction en temps r\u00e9el et une conformit\u00e9 imm\u00e9diate, ce qui am\u00e9liore \u00e0 la fois l&rsquo;efficacit\u00e9 et les taux de conformit\u00e9.<\/p>\n<h2>FAQ<\/h2>\n<p><strong>Q\u00a0: Le script est-il facile \u00e0 adapter \u00e0 diff\u00e9rentes situations ? \u00a0<\/strong><br \/>\nR\u00a0: Oui, les param\u00e8tres du script sont con\u00e7us pour \u00eatre facilement adapt\u00e9s \u00e0 diff\u00e9rents cas d&rsquo;utilisation.<\/p>\n<p><strong>Q\u00a0: Le script peut-il forcer des actions sur la machine de l&rsquo;utilisateur ? \u00a0<\/strong><br \/>\nR\u00a0: Bien que le script puisse susciter des actions, il repose sur l&rsquo;interaction de l&rsquo;utilisateur et respecte le contr\u00f4le qu&rsquo;il exerce sur son appareil.<\/p>\n<p><strong>Q\u00a0: Est-il compatible avec toutes les versions de macOS ? \u00a0<\/strong><br \/>\nR\u00a0: Il est con\u00e7u pour macOS, mais il est recommand\u00e9 de le tester sur les versions sp\u00e9cifiques de votre environnement.<\/p>\n<h2>Implications<\/h2>\n<p>Si ce script am\u00e9liore la gestion informatique, il soul\u00e8ve \u00e9galement des pr\u00e9occupations concernant l&rsquo;autonomie et la vie priv\u00e9e des utilisateurs. Il est primordial de veiller \u00e0 ce qu&rsquo;il soit utilis\u00e9 de mani\u00e8re transparente et \u00e9thique.<\/p>\n<h2>Recommandations<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Testez le script de mani\u00e8re approfondie dans un environnement contr\u00f4l\u00e9 avant de le d\u00e9ployer.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Communiquez clairement avec les utilisateurs sur l&rsquo;objectif et la fonction des fen\u00eatres pop-up.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\">Utilisez cet outil de mani\u00e8re responsable et veillez \u00e0 ce qu&rsquo;il soit conforme aux politiques de l&rsquo;entreprise et aux r\u00e8gles d&rsquo;\u00e9thique.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>Ce script r\u00e9pond parfaitement aux objectifs de NinjaOne, une plateforme connue pour <a href=\"https:\/\/www.ninjaone.com\/fr\/rmm\/automatisation-informatique\/\">am\u00e9liorer la gestion et la s\u00e9curit\u00e9 informatique<\/a>. Il repr\u00e9sente l&rsquo;un des nombreux outils qui peut permettre aux professionnels de l&rsquo;informatique de g\u00e9rer leurs environnements de mani\u00e8re plus efficace. L&rsquo;int\u00e9gration de tels scripts personnalisables dans les flux de travail informatiques peut consid\u00e9rablement am\u00e9liorer <a href=\"https:\/\/www.ninjaone.com\/fr\/efficacite\">l&rsquo;efficacit\u00e9 et la r\u00e9activit\u00e9 des syst\u00e8mes informatiques<\/a>, qui sont des \u00e9l\u00e9ments important de la gestion informatique par NinjaOne.<\/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":[4289],"class_list":["post-310249","script_hub","type-script_hub","status-publish","hentry","script_hub_category-macos","use_cases-gestion-des-utilisateurs-et-des-acces"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/script_hub\/310249","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=310249"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/media?parent=310249"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/operating_system?post=310249"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/fr\/wp-json\/wp\/v2\/use_cases?post=310249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}