{"id":237120,"date":"2024-04-16T13:15:44","date_gmt":"2024-04-16T13:15:44","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=237120"},"modified":"2024-04-16T13:15:44","modified_gmt":"2024-04-16T13:15:44","slug":"messaggi-popup-personalizzati-per-macos","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/it\/script-hub\/messaggi-popup-personalizzati-per-macos\/","title":{"rendered":"Guida completa ai messaggi popup personalizzati per macOS"},"content":{"rendered":"<h2>Punti chiave<\/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\">Lo script crea messaggi popup personalizzabili su macOS, migliorando la comunicazione diretta tra professionisti IT e utenti finali.<\/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\">Offre ampie possibilit\u00e0 di personalizzazione per titolo, messaggio, pulsanti, icone e azioni del popup.<\/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\">Gli utenti possono impostare azioni specifiche da eseguire quando si preme un pulsante o quando il popup si chiude, facilitando le attivit\u00e0 di gestione IT automatizzate.<\/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\">Lo script per i messaggi popup personalizzati per macOS include controlli per i comuni errori di configurazione, garantendo un funzionamento affidabile e sicuro.<\/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\">Rispetto ai metodi tradizionali come le e-mail, lo script offre un modo pi\u00f9 immediato e interattivo di trasmettere i messaggi.<\/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\">L&#8217;uso etico e la trasparenza sono essenziali, vista la capacit\u00e0 dello script di sollecitare azioni dirette dell&#8217;utente.<\/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\">Per un&#8217;implementazione efficace si raccomanda di eseguire test approfonditi e di comunicare chiaramente con gli utenti.<\/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\">Lo script integra strumenti come NinjaOne, migliorando l&#8217;efficienza e il controllo della gestione IT.<\/li>\n<\/ul>\n<h2>Introduzione<\/h2>\n<p>La capacit\u00e0 di comunicare e gestire efficacemente le azioni degli utenti \u00e8 un aspetto importante della <a href=\"https:\/\/www.ninjaone.com\/it\/gestione-impresa\/infrastruttura\">gestione dell&#8217;infrastruttura IT.<\/a> Uno script che crea messaggi popup personalizzabili sui dispositivi macOS rappresenta questa necessit\u00e0, fornendo uno strumento versatile per gli amministratori di sistema e i <a href=\"https:\/\/www.ninjaone.com\/it\/cos-e-un-msp\">fornitori di servizi gestiti (MSP). \u00a0<\/a><\/p>\n<h2>Background<\/h2>\n<p>La funzione principale di questo script Bash \u00e8 quella di generare messaggi popup personalizzabili su macOS, offrendo una variet\u00e0 di parametri per la personalizzazione. Questa funzione \u00e8 particolarmente utile per i professionisti IT e gli MSP che devono richiedere azioni o trasmettere informazioni direttamente agli utenti finali in modo controllato ed efficiente. La sua importanza deriva dalla necessit\u00e0 di semplificare la comunicazione in modo non invasivo, ma diretto.<\/p>\n<h2>Lo script per i messaggi popup personalizzati per macOS:<\/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\/it\/condizioni-utilizzo\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>Accedi a oltre 700 script nel Dojo NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/it\/prova-gratuita\/\">Ottieni l&#8217;accesso<\/a><\/p>\n<\/div>\n<h2>Analisi dettagliata<\/h2>\n<p>Lo script comincia inizializzando i valori predefiniti e analizzando gli argomenti della riga di comando per personalizzare vari elementi del popup, come il titolo, il messaggio, i pulsanti e le azioni associate a questi pulsanti. I parametri consentono di personalizzare l&#8217;aspetto e il comportamento del popup, come l&#8217;impostazione di un&#8217;icona, la durata del timeout e le azioni da eseguire quando si preme un pulsante o al timeout.<\/p>\n<p>Una delle funzionalit\u00e0 dello script \u00e8 il download e l&#8217;impostazione di un&#8217;icona personalizzata per il popup, a dimostrazione della sua versatilit\u00e0. Inoltre, gestisce diversi scenari, come un utente che ignora il popup o che preme uno dei pulsanti, ognuno dei quali attiva azioni specifiche.<\/p>\n<p>Lo script \u00e8 efficace, effettuando controlli per errori come la denominazione impropria dei pulsanti o valori di timeout non validi. Queste garanzie assicurano un&#8217;esecuzione senza problemi e prevengono gli errori pi\u00f9 comuni durante la configurazione.<\/p>\n<h2>Casi d&#8217;uso potenziali<\/h2>\n<p>Un professionista IT in un ambiente aziendale potrebbe utilizzare questo script per ricordare ai dipendenti di riavviare i computer per gli aggiornamenti software. La capacit\u00e0 dello script di pianificare i riavvii e di fornire opzioni per posticiparli o avviarli immediatamente lo rende ideale per mantenere un ambiente IT aggiornato e sicuro.<\/p>\n<h2>Confronti<\/h2>\n<p>Tradizionalmente, i reparti IT potrebbero affidarsi a notifiche via e-mail o a interventi manuali per tali attivit\u00e0. Lo script offre un approccio pi\u00f9 diretto e facile da usare, fornendo un&#8217;interazione in tempo reale e una conformit\u00e0 immediata, migliorando sia l&#8217;efficienza che i tassi di conformit\u00e0.<\/p>\n<h2>Domande frequenti<\/h2>\n<p><strong>D: Lo script \u00e8 facile da personalizzare per diversi scenari? \u00a0<\/strong><br \/>\nR: S\u00ec, i parametri dello script sono stati progettati per essere facilmente personalizzati per adattarsi ai vari casi d&#8217;uso.<\/p>\n<p><strong>D: Lo script pu\u00f2 forzare le azioni sul computer dell&#8217;utente? \u00a0<\/strong><br \/>\nR: Anche se lo script pu\u00f2 richiedere azioni, si basa sull&#8217;interazione dell&#8217;utente, rispettando il controllo che esso ha sul proprio dispositivo.<\/p>\n<p><strong>D: \u00c8 compatibile con tutte le versioni di macOS? \u00a0<\/strong><br \/>\nR: \u00c8 stato progettato per macOS, ma si consiglia di testarlo sulle versioni specifiche del tuo ambiente.<\/p>\n<h2>Implicazioni<\/h2>\n<p>Se da un lato questo script migliora la gestione dell&#8217;IT, dall&#8217;altro solleva preoccupazioni in merito all&#8217;autonomia e alla privacy degli utenti. \u00c8 fondamentale garantire un utilizzo trasparente ed etico.<\/p>\n<h2>Raccomandazioni<\/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\">Testa accuratamente lo script in un ambiente controllato prima della distribuzione.<\/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\">Comunica in modo chiaro agli utenti lo scopo e la funzione dei popup.<\/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\">Utilizza questo strumento in modo responsabile e assicurati che sia conforme alle politiche aziendali e alle linee guida etiche.<\/li>\n<\/ul>\n<h2>Considerazioni finali<\/h2>\n<p>Nel contesto di NinjaOne, una piattaforma nota per il <a href=\"https:\/\/www.ninjaone.com\/it\/rmm\/automazione-it\">miglioramento della gestione IT<\/a> e della sicurezza IT, questo script si allinea perfettamente con i suoi obiettivi. Rappresenta una parte piccola, ma significativa, di un set di strumenti pi\u00f9 ampio che pu\u00f2 consentire ai professionisti IT di gestire i propri ambienti in modo pi\u00f9 efficace. L&#8217;integrazione di tali script personalizzabili nei flussi di lavoro IT pu\u00f2 aumentare significativamente <a href=\"https:\/\/www.ninjaone.com\/it\/efficienza-it\">l&#8217;efficienza e la reattivit\u00e0 dei sistemi IT<\/a>, un pilastro della moderna gestione IT sostenuta da 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":[4277],"class_list":["post-237120","script_hub","type-script_hub","status-publish","hentry","script_hub_category-macos","use_cases-gestione-degli-utenti-e-degli-accessi"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub\/237120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/comments?post=237120"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/media?parent=237120"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/operating_system?post=237120"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/it\/wp-json\/wp\/v2\/use_cases?post=237120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}