{"id":815654,"date":"2026-05-28T12:26:40","date_gmt":"2026-05-28T12:26:40","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=815654"},"modified":"2026-05-28T12:26:40","modified_gmt":"2026-05-28T12:26:40","slug":"script-de-implantacao-de-mensagens-pop-up-do-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/script-de-implantacao-de-mensagens-pop-up-do-powershell\/","title":{"rendered":"Aprimoramento da comunica\u00e7\u00e3o de TI: Dom\u00ednio das mensagens pop-up do PowerShell"},"content":{"rendered":"<h2>Principais conclus\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Comunica\u00e7\u00e3o aprimorada com o usu\u00e1rio:<\/strong> O script melhora significativamente a forma como <a href=\"https:\/\/www.ninjaone.com\/blog\/improve-it-communication\/\">a TI comunica<\/a> a\u00e7\u00f5es importantes aos usu\u00e1rios.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Pop-ups personaliz\u00e1veis:<\/strong> Oferece amplas op\u00e7\u00f5es de personaliza\u00e7\u00e3o para mensagens pop-up, incluindo texto, bot\u00f5es e imagens.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Adapt\u00e1vel a v\u00e1rias vers\u00f5es do Windows:<\/strong> Compat\u00edvel com sistemas Windows modernos e antigos, garantindo ampla aplicabilidade.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Integra\u00e7\u00e3o de imagens Base64:<\/strong> Recurso exclusivo para usar imagens codificadas em base64, eliminando a necessidade de arquivos externos.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>A\u00e7\u00f5es automatizadas do usu\u00e1rio:<\/strong> Permite respostas automatizadas do usu\u00e1rio, como reinicializa\u00e7\u00f5es do sistema, melhorando a conformidade e a efici\u00eancia.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Superior aos m\u00e9todos tradicionais:<\/strong> Mais eficaz e menos demorado em compara\u00e7\u00e3o com e-mails ou lembretes manuais.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Versatilidade no uso:<\/strong> Pode ser adaptado para uma variedade de avisos de notifica\u00e7\u00e3o e a\u00e7\u00e3o al\u00e9m dos lembretes de reinicializa\u00e7\u00e3o.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Interface amig\u00e1vel ao usu\u00e1rio:<\/strong> Aprimora a experi\u00eancia do usu\u00e1rio com \u00edcones e interfaces de usu\u00e1rio personalizados.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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=\"9\" data-aria-level=\"1\"><strong>Responsabilidade no uso:<\/strong> Enfatiza a necessidade do uso respons\u00e1vel para evitar a fadiga de notifica\u00e7\u00f5es.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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=\"10\" data-aria-level=\"1\"><strong>Potencial de integra\u00e7\u00e3o com <a href=\"https:\/\/www.ninjaone.com\/pt-br\/blog\/melhor-msp-software\/\">ferramentas MSP<\/a>:<\/strong> Pode ser integrado a ferramentas como o NinjaOne para simplificar os processos de gerenciamento de TI.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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=\"11\" data-aria-level=\"1\"><strong>Import\u00e2ncia dos testes e atualiza\u00e7\u00f5es:<\/strong> \u00c9 essencial testar exaustivamente e manter o script atualizado para novas vers\u00f5es do Windows.<\/li>\n<\/ul>\n<p>No cen\u00e1rio din\u00e2mico do gerenciamento de TI, a comunica\u00e7\u00e3o eficaz com os usu\u00e1rios finais \u00e9 fundamental. Isso inclui a capacidade de notific\u00e1-los prontamente sobre as a\u00e7\u00f5es necess\u00e1rias, como reinicializa\u00e7\u00f5es ou atualiza\u00e7\u00f5es do sistema. <a href=\"https:\/\/www.ninjaone.com\/blog\/category\/scripts\/\">Os scripts do PowerShell<\/a>, que oferecem uma combina\u00e7\u00e3o de flexibilidade e efici\u00eancia, est\u00e3o se tornando cada vez mais a solu\u00e7\u00e3o ideal para essas tarefas.<\/p>\n<h2>Hist\u00f3rico<\/h2>\n<p>O script do PowerShell fornecido \u00e9 uma ferramenta avan\u00e7ada projetada para <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a> e profissionais de TI. Permite a exibi\u00e7\u00e3o de mensagens pop-up personaliz\u00e1veis nas telas dos usu\u00e1rios. Esse script \u00e9 particularmente valioso para lembrar ou instruir os usu\u00e1rios a realizar a\u00e7\u00f5es espec\u00edficas, como reiniciar o computador ap\u00f3s atualiza\u00e7\u00f5es ou manuten\u00e7\u00e3o.<\/p>\n<h2>O roteiro:<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">&lt;#\r\n.SYNOPSIS\r\n    Displays a popup on the end user's screen. The script needs to be run as the 'Current Logged In User'. Use \"Restart Reminder\" to display a request to the end user to restart their computer.\r\n.DESCRIPTION\r\n    Displays a popup on the end user's screen. The script needs to be run as the 'Current Logged In User'. Use \"Restart Reminder\" to display a request to the end user to restart their computer. \r\n    See the comment block in this script's code for extra options such as changing the logo or the window title.\r\n    Uses Windows Presentation Framework to accommodate different DPIs and image scaling. On Windows 7 and Server 2008, the script will use the older Windows Form UI.\r\n\r\n    You can also convert an image to base64 and replace either lines 164 or 168 if you'd prefer to not have to download an image to a machine. \r\n.EXAMPLE\r\n    (No Parameters on Windows 11)\r\n\r\n    Result: Success\r\n\r\nPARAMETER: -RestartReminder\r\n    Displays a generic prompt requesting the user restart their machine. \r\n    This parameter is equivalent to the below options.\r\n    -Text \"Your IT Administrator is requesting that you restart your computer. Click 'Restart Now' after saving your work.\"\r\n    -ButtonLText \"Restart Now\"\r\n    -ButtonLaction \"shutdown.exe \/r \/t 30\"\r\n    -ButtonRText \"Ignore\"\r\n    -ButtonRcountdown 900\r\n    -ButtonRDefault\r\n.EXAMPLE\r\n    -RestartReminder (Server 2008)\r\n    \r\n    WARNING: PowerShell 2 cannot import the presentation framework switching to winform...\r\n    Ignore (895) Button Clicked!\r\n\r\nPARAMETER: -ApplicationID \"ReplaceWithWindowTitle\/ApplicationID\"\r\n    This will replace the window title and it will also change the taskbar overlay icon and logo\/image used in the popup \r\n    with the Notification Icon used by that Application ID  if it exists and is not overridden by another parameter. \r\n    This is the same application ID used by the Send-UserPrompt and the built-in Windows notification system.\r\n.EXAMPLE\r\n    -ApplicationID \"Contoso Inc\"\r\n    \r\n    Application ID with Icon found! Checking if the icon and logo were supplied elsewhere...\r\n    The icon was not specified elsewhere in the script switching from the default icon to the Applications Notification Icon.\r\n    The logo\/image was not specified elsewhere in the script switching from the default image to the Applications Notification Icon.\r\n    You can also switch the default Application ID on line 128\r\n\r\nPARAMETER: -LogoPath \"C:ReplaceThisPath.png\"\r\n    The location of an image you would like to use in the large image window.\r\n    This script is running as the end-user so their account will need permission to this path.\r\n    Can be given a URL. Just keep in mind that Ninja doesn't support these special characters: &amp;|;$&gt;&lt;`!.\r\n    Can be given any size image however the script will center it and then scale it into a 250px x 125px rectangle. \r\n    The image will always be centered and a square 1:1 ratio will work.\r\n    Scaling is not done on Server 2008 and Windows 7 (The image is simply centered and you may see it cut off the image if the image is too large).\r\n    \r\n    Supported image formats: .png, .jpg, .ico, .gif (GIFs will be static and not animated.)\r\n    \r\n    You can also convert an image to base64 and replace either lines 165 or 169 if you'd prefer to not have to download an image and give the script a path to it. \r\n\r\nPARAMETER: -IconPath \"C:ReplaceThisPath.png\"\r\n    The location of an icon you would like to use for the taskbar overlay and window title bar. \r\n    This script is running as the end-user so their account will need permission to this path.\r\n    Can be given a URL. Just keep in mind that Ninja doesn't support these special characters: &amp;|;$&gt;&lt;`!.\r\n    Can be given any icon size however the script will convert it to 64px x 64px so it is recommended to keep to the 1:1 ratio so that the image is not squished.\r\n    \r\n    Supported image formats: .png, .jpg, .ico, .gif (GIFs will be static and not animated.)\r\n    \r\n    You can also convert an image to base64 and replace either lines 164 or 168 if you'd prefer to not have to download an image and give the script a path to it.\r\n\r\nPARAMETER: -Text \"ReplaceMeWithTextYouWantInsideThePopUp\"\r\n    The text you would like displayed inside the popup. \r\n    If too much text is written, a scrollbar will automatically appear, allowing the end-user to view all the text.\r\n\r\nPARAMETER: -AllowResize\r\n    By default, resizing the popup is not allowed. Use -AllowResize to allow resizing the window.\r\n\r\nPARAMETER: -ButtonR\r\n    Add a button to the bottom right (can only be specified once).\r\n\r\nPARAMETER: -ButtonRdefault\r\n    Set the right button as the default button. This will allow end-users to simply hit the enter key when the window is in focus to perform a click.\r\n\r\nPARAMETER: -ButtonRtext \"TextYouWouldLikeInsideTheButton\"\r\n    Change the text from 'Right Button' to whatever you put encased in quotes.\r\n.EXAMPLE\r\n    -ButtonRtext \"Later\"\r\n\r\n    Later Button Clicked!\r\n\r\nPARAMETER: -ButtonRaction \"ReplaceWithAnyCMDcommand\"\r\n    This will set the action the right button performs when clicked. Can be given any command that will work in cmd.exe as well as parameters. ex. logoff.exe \r\n\r\nPARAMETER: -ButtonRcountdown \"160\"\r\n    This will add a countdown to the right button with your input in seconds. When the countdown reaches 0 it'll click the button for the end user.\r\n    The left and right button countdown cannot be used at the same time.\r\n\r\nPARAMETER: -ButtonL\r\n    Add a button to the bottom left (can only be specified once).\r\n\r\nPARAMETER: -ButtonLdefault\r\n    Set the left button as the default button. This will allow end-users to simply hit the enter key when the window is in focus to perform a click.\r\n\r\nPARAMETER: -ButtonLtext \"TextYouWouldLikeInsideTheButton\"\r\n    Change the text from 'Left Button' to whatever you put encased in quotes.\r\n.EXAMPLE\r\n    -ButtonLtext \"Later\"\r\n\r\n    Later Button Clicked!\r\n\r\nPARAMETER: -ButtonLaction \"ReplaceWithAnyCMDcommand\"\r\n    This will set the action the left button performs when clicked. Can be given any command that will work in cmd.exe as well as parameters. ex. logoff.exe \r\n\r\nPARAMETER: -ButtonLcountdown\r\n    This will add a countdown to the left button with your input in seconds. When the countdown reaches 0 it'll click the button for the end user.\r\n    The left and right button countdown cannot be used at the same time.\r\n\r\nPARAMETER: -Verbose\r\n    More verbose output (useful for troubleshooting).\r\n.OUTPUTS\r\n  None\r\n.NOTES\r\n  Minimum OS Architecture Supported: Windows 7+, Server 2008+\r\n  Release Notes:\r\n  Initial Release\r\nBy 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#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [Switch]$AllowResize = [System.Convert]::ToBoolean($env:allowEnduserToResizeWindow),\r\n    # You can set line 127 to [String]$ApplicationID = \"$env:NINJA_COMPANY_NAME\" to automatically use your company name.\r\n    [Parameter()]\r\n    [String]$ApplicationID = \"NinjaOne RMM\",\r\n    [Parameter()]\r\n    [Switch]$ButtonR,\r\n    [Parameter()]\r\n    [Switch]$ButtonRdefault,\r\n    [Parameter()]\r\n    [String]$ButtonRtext,\r\n    [Parameter()]\r\n    [String]$ButtonRaction,\r\n    [Parameter()]\r\n    [int]$ButtonRcountdown,\r\n    [Parameter()]\r\n    [Switch]$ButtonL,\r\n    [Parameter()]\r\n    [Switch]$ButtonLDefault,\r\n    [Parameter()]\r\n    [String]$ButtonLtext,\r\n    [Parameter()]\r\n    [String]$ButtonLaction,\r\n    [Parameter()]\r\n    [int]$ButtonLcountdown,\r\n    [Parameter()]\r\n    [String]$IconPath,\r\n    [Parameter()]\r\n    [String]$LogoPath,\r\n    [Parameter()]\r\n    [String]$Text,\r\n    [Parameter()]\r\n    [Switch]$winForm,\r\n    [Parameter()]\r\n    [Switch]$RestartReminder = [System.Convert]::ToBoolean($env:restartReminder)\r\n)\r\n\r\nbegin {\r\n\r\n    # You can replace the below line with $IconBase64 = \"ReplaceThisWithYourBase64encodedimageEncasedInQuotes\" and the script will decode the image and use it \r\n    # for the taskbar overlay icon and title bar icon.\r\n    $IconBase64 = \"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\n    \r\n    # You can replace the below line with $LogoBase64 = \"ReplaceThisWithYourBase64encodedimageEncasedInQuotes\" and the script will decode the image and use it \r\n    # for the main large image \/ logo\r\n    $LogoBase64 = \"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\n\r\n    # If script form is used replace the parameters\r\n    if ($env:applicationId -and $env:applicationId -notlike \"null\") { $ApplicationID = $env:applicationId }\r\n    if ($env:logoPath -and $env:logoPath -notlike \"null\") { $LogoPath = $env:logoPath }\r\n    if ($env:iconPath -and $env:iconPath -notlike \"null\") { $IconPath = $env:iconPath }\r\n    if ($env:popupMessage -and $env:popupMessage -notlike \"null\") { $Text = $env:popupMessage }\r\n    if ($env:rightButtonText -and $env:rightButtonText -notlike \"null\") { $ButtonRtext = $env:rightButtonText }\r\n    if ($env:rightButtonAction -and $env:rightButtonAction -notlike \"null\") { $ButtonRaction = $env:rightButtonAction }\r\n    if ($env:rightButtonCountdown -and $env:rightButtonCountdown -notlike \"null\") { $ButtonRcountdown = $env:rightButtonCountdown }\r\n    if ($env:leftButtonText -and $env:leftButtonText -notlike \"null\") { $ButtonLText = $env:leftButtonText }\r\n    if ($env:leftButtonAction -and $env:leftButtonAction -notlike \"null\") { $ButtonLaction = $env:leftButtonAction }\r\n    if ($env:leftButtonCountdown -and $env:leftButtonCountdown -notlike \"null\") { $ButtonLcountdown = $env:leftButtonCountdown }\r\n    if ($env:defaultButton -and $env:defaultButton -notlike \"null\") {\r\n        if ($env:defaultButton -eq \"Right Button\") { $ButtonRdefault = $True }\r\n        if ($env:defaultButton -eq \"Left Button\") { $ButtonLdefault = $True }\r\n    }\r\n\r\n    # Sets the parameters for a generic restart prompt\r\n    if ($RestartReminder) {\r\n        if (-not $ButtonLtext) { $ButtonLtext = \"Restart Now\" }\r\n        if (-not $ButtonLaction) {\r\n            if (([System.Environment]::OSVersion.Version).Major -ge 10) {\r\n                $ButtonLaction = \"shutdown.exe \/r \/soft \/t 30\"\r\n            }\r\n            else {\r\n                $ButtonLaction = \"shutdown.exe \/r \/t 30\"\r\n            } \r\n        }\r\n        if (-not $ButtonRtext) { $ButtonRtext = \"Ignore\" }\r\n        if (-not $ButtonRcountdown) { $ButtonRcountdown = 900 }\r\n        if (-not $Text) { $Text = \"Your IT Administrator is requesting that you restart your computer. Click 'Restart Now' after saving your work.\" }\r\n    }\r\n\r\n    # These Assemblies are needed to prepare the images for the form\r\n    Write-Verbose \"Adding required assemblies...\"\r\n    Add-Type -AssemblyName System.Windows.Forms\r\n    Add-Type -AssemblyName System.Drawing\r\n\r\n    # Check if the script was run as the default System User\r\n    function Test-IsSystem {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        return $id.Name -like \"NT AUTHORITY*\" -or $id.IsSystem\r\n    }\r\n\r\n    function Test-PSVersion {\r\n        return ($PSVersionTable.PSVersion.Major)\r\n    }\r\n\r\n    function ConvertFrom-Base64 {\r\n        param(\r\n            $Base64,\r\n            $Path\r\n        )\r\n        $bytes = [Convert]::FromBase64String($Base64)\r\n\r\n        # This section of code will error out when ran multiple times in the same session. This is from wpf holding onto the file after closing. \r\n        # The file is unlocked when the powershell session is closed.\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\r\n        [IO.File]::WriteAllBytes($Path, $bytes)\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n    }\r\n\r\n    # There's a lot of ways to create icon files the below method creates a png and then creates an ico file in binary form by creating the header and adding the png's binary at the bottom.\r\n    # Once this has been done we can simply write all the bytes to our new file.\r\n    function ConvertFrom-Image {\r\n        param(\r\n            $ImagePath,\r\n            $Path\r\n        )\r\n\r\n        # Grab an instance of the image and blank bitmap\r\n        $image = [Drawing.Image]::FromFile($ImagePath)\r\n\r\n        # Resize the image to 255px by 255px while maintaining quality.\r\n        # If you want transparency you'll need an Alpha channel in the pixel format\r\n        $bitmap = New-Object System.Drawing.Bitmap (64, 64, [system.drawing.imaging.PixelFormat]::Format32bppArgb)\r\n        $bitmap.SetResolution(64, 64)\r\n\r\n        # Create a graphics object which will be used to resize the image to 255px by 255px\r\n        $graphics = [System.Drawing.Graphics]::FromImage($bitmap)\r\n\r\n        # Set some quality settings for the resize operation\r\n        $graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality\r\n        $graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic\r\n        $graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality\r\n\r\n        # Draw the image onto the bitmap\r\n        $graphics.DrawImage($Image, 0, 0, 64, 64)\r\n        \r\n        # Temporarily save the image as a png\r\n        $RandomNumber = Get-Random -Maximum 1000000\r\n        $bitmap.Save(\"$env:TEMPimage-$RandomNumber.png\", [System.Drawing.Imaging.ImageFormat]::Png)\r\n        $png = \"$env:TEMPimage-$RandomNumber.png\"\r\n\r\n        # Build the ico file using the png binary.\r\n        if ($PSVersionTable.PSVersion.Major -gt 5) {\r\n            $pngBytes = Get-Content -Path $png -AsByteStream\r\n        }\r\n        elseif ($PSVersionTable.PSVersion.Major -gt 2) {\r\n            $pngBytes = Get-Content -Path $png -Encoding Byte -Raw\r\n        }\r\n        else {\r\n            $pngBytes = [System.IO.File]::ReadAllBytes($png)\r\n        }\r\n        $icoHeader = [byte[]] @(0, 0, 1, 0, 1, 0)\r\n        $imageDataSize = $pngBytes.Length\r\n        $icoDirectory = [byte[]] @(\r\n            64, 64, # icon size\r\n            0, 0, # color count\r\n            0, 0, # reserved\r\n            0, 0, # hotspot x, hotspot y\r\n            ($imageDataSize -band 0xFF),\r\n            ([Math]::Floor($imageDataSize \/ [Math]::Pow(2, 8)) -band 0xFF),\r\n            ([Math]::Floor($imageDataSize \/ [Math]::Pow(2, 16)) -band 0xFF),\r\n            ([Math]::Floor($imageDataSize \/ [Math]::Pow(2, 24)) -band 0xFF),\r\n            22, 0, 0, 0  # offset to image data\r\n        )\r\n        $iconData = $icoHeader + $icoDirectory + $pngBytes\r\n\r\n        # Save the completed icon file and clean up any temporary files.\r\n        # This section of code will error out when ran multiple times in the same session. This is from wpf holding onto the file after closing. \r\n        # The file is unlocked when the powershell session is closed.\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\r\n        if (Test-Path $Path -ErrorAction SilentlyContinue) { Remove-Item $Path -Force }\r\n        [System.IO.File]::WriteAllBytes($Path, $iconData)\r\n\r\n        if (Test-Path $png -ErrorAction SilentlyContinue) { Remove-Item $png -Force }\r\n        $bitmap.Dispose()\r\n        $image.Dispose()\r\n        $graphics.Dispose()\r\n        [System.GC]::Collect()\r\n\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n    }\r\n\r\n    function Invoke-Download {\r\n        param(\r\n            [Parameter()]\r\n            [String]$URL,\r\n            [Parameter()]\r\n            [String]$BaseName,\r\n            [Parameter()]\r\n            [Switch]$SkipSleep\r\n        )\r\n        Write-Host \"URL Given, Downloading the file...\"\r\n\r\n        $SupportedTLSversions = [enum]::GetValues('Net.SecurityProtocolType')\r\n        if ( ($SupportedTLSversions -contains 'Tls13') -and ($SupportedTLSversions -contains 'Tls12') ) {\r\n            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol::Tls13 -bor [System.Net.SecurityProtocolType]::Tls12\r\n        }\r\n        elseif ( $SupportedTLSversions -contains 'Tls12' ) {\r\n            [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12\r\n        }\r\n        else {\r\n            # Not everything requires TLS 1.2, but we'll try anyways.\r\n            Write-Warning \"TLS 1.2 and or TLS 1.3 isn't supported on this system. This download may fail!\"\r\n            if ($PSVersionTable.PSVersion.Major -lt 3) {\r\n                Write-Warning \"PowerShell 2 \/ .NET 2.0 doesn't support TLS 1.2.\"\r\n            }\r\n        }\r\n\r\n        $i = 1\r\n        While ($i -lt 4) {\r\n            if (-not ($SkipSleep)) {\r\n                $SleepTime = Get-Random -Minimum 3 -Maximum 30\r\n                Start-Sleep -Seconds $SleepTime\r\n            }\r\n\r\n            Write-Host \"Download Attempt $i\"\r\n\r\n            try {\r\n                $WebClient = New-Object System.Net.WebClient\r\n                $Response = $WebClient.OpenRead($Url)\r\n                $MimeType = $WebClient.ResponseHeaders[\"Content-Type\"]\r\n                $DesiredExtension = switch -regex ($MimeType) {\r\n                    \"image\/jpeg|image\/jpg\" { \"jpg\" }\r\n                    \"image\/png\" { \"png\" }\r\n                    \"image\/gif\" { \"gif\" }\r\n                    \"image\/bmp|image\/x-windows-bmp|image\/x-bmp\" { \"bmp\" }\r\n                    \"image\/x-icon\" { \"ico\" }\r\n                    default { \r\n                        Write-Error \"The URL you provided does not provide a supported image type. Image Types Supported: jpg, jpeg, ico, bmp, png and gif. Image Type detected: $MimeType\"\r\n                        Exit 1 \r\n                    }\r\n                }\r\n                $Path = \"$BaseName.$DesiredExtension\"\r\n                $WebClient.DownloadFile($URL, $Path)\r\n                $File = Test-Path -Path $Path -ErrorAction SilentlyContinue\r\n                $Response.Close()\r\n            }\r\n            catch {\r\n                if ($Response) { $Response.Close() }\r\n                Write-Warning \"An error has occured while downloading!\"\r\n                Write-Warning $_.Exception.Message\r\n            }\r\n\r\n            if ($File) {\r\n                $i = 4\r\n            }\r\n            else {\r\n                $i++\r\n            }\r\n        }\r\n\r\n        if (-not (Test-Path $Path)) {\r\n            Write-Error \"Failed to download file!\"\r\n            Exit 1\r\n        }\r\n\r\n        $Path\r\n    }\r\n\r\n    function Build-WPFform {\r\n        # This is xml I created using visual studio community edition https:\/\/visualstudio.microsoft.com\/downloads\/ I removed some of the lines in \"Window\" so PowerShell could load it.\r\n        [XML]$form = @\"\r\n&lt;Window\r\n\r\nxmlns_x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\r\nWidth=\"350\" WindowStartupLocation=\"CenterScreen\" SizeToContent=\"Height\" ResizeMode=\"CanMinimize\" Topmost=\"True\"\r\n&gt;\r\n    &lt;Window.TaskbarItemInfo&gt;\r\n        &lt;TaskbarItemInfo\/&gt;\r\n    &lt;\/Window.TaskbarItemInfo&gt;\r\n    &lt;Grid&gt;\r\n        &lt;Grid x_Name=\"ImageGrid\" Margin=\"25,25,25,0\" Height=\"125\" MinWidth=\"250\" VerticalAlignment=\"Top\"&gt;\r\n        &lt;Image x_Name=\"Logo\" HorizontalAlignment=\"Center\" \/&gt;\r\n        &lt;\/Grid&gt;\r\n        &lt;Grid x_Name=\"ContentGrid\" Margin=\"25,188,25,25\"&gt;\r\n            &lt;Grid.RowDefinitions&gt;\r\n                &lt;RowDefinition MinHeight=\"65\" \/&gt;\r\n                &lt;RowDefinition Height=\"30\" \/&gt;\r\n            &lt;\/Grid.RowDefinitions&gt;\r\n            &lt;ScrollViewer x_Name=\"ScrollBox\" VerticalScrollBarVisibility=\"Auto\" Grid.RowSpan=\"1\" MaxHeight=\"100\" &gt;\r\n                &lt;TextBlock x_Name=\"TextBlock\" TextWrapping=\"Wrap\" FontFamily=\"Microsoft Sans Serif\" FontSize=\"14\" \/&gt;\r\n            &lt;\/ScrollViewer&gt;\r\n            &lt;Button x_Name=\"ButtonR\" FontFamily=\"Lucida Sans Unicode\" FontSize=\"12\" Content=\"Accept\" Margin=\"0,0,0,0\" Height=\"30\" Width=\"114\" HorizontalAlignment=\"Right\" VerticalAlignment=\"Bottom\" Grid.RowSpan=\"2\" Visibility=\"Hidden\" \/&gt;\r\n            &lt;Button x_Name=\"ButtonL\" FontFamily=\"Lucida Sans Unicode\" FontSize=\"12\" Content=\"Close\" Margin=\"0,0,0,0\" Height=\"30\" Width=\"114\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Bottom\" Grid.RowSpan=\"2\" Visibility=\"Hidden\" \/&gt;\r\n        &lt;\/Grid&gt;\r\n    &lt;\/Grid&gt;\r\n&lt;\/Window&gt;\r\n\"@\r\n\r\n        $NR = (New-Object System.Xml.XmlNodeReader $form)\r\n        # Informs powershell that this xml is actually Xaml (Presentation Framework is needed to load it)\r\n        $Window = [Windows.Markup.XamlReader]::Load($NR)\r\n\r\n        # Set's the details of the form (How many buttons? Is One Default? All the options set by parameters)\r\n        if ($ApplicationID) {\r\n            Write-Verbose \"Setting window title to $ApplicationID\"\r\n            $Window.Title = $ApplicationID\r\n        }\r\n\r\n        if ($AllowResize) {\r\n            Write-Verbose \"Allowing ReSizing of window...\"\r\n            $Window.ResizeMode = \"CanResize\"\r\n        }\r\n\r\n        if ($LogoPath) {\r\n            Write-Verbose \"Adding Logo...\"\r\n            $Logo = $window.FindName(\"Logo\")\r\n            $Logo.Source = $LogoPath\r\n        }\r\n\r\n        if ($IconPath) {\r\n            Write-Verbose \"Overlaying tasbar icon and setting icon for window...\"\r\n            $Window.Icon = $IconPath\r\n            $Window.TaskbarItemInfo.Overlay = $IconPath\r\n        }\r\n\r\n        if ($Text) {\r\n            Write-Verbose \"Adding Text Block...\"\r\n            $TextBlock = $window.FindName(\"TextBlock\")\r\n            $TextBlock.Text = $Text\r\n        }\r\n\r\n        if ($ButtonR -or $ButtonRtext) {\r\n            Write-Verbose \"Adding Right Button...\"\r\n            $RightButton = $window.FindName(\"ButtonR\")\r\n\r\n            if ($ButtonRtext) { \r\n                Write-Verbose \"Setting Right Button Text...\"\r\n                $RightButton.Content = $ButtonRtext \r\n            }\r\n            else {\r\n                Write-Warning \"It looks like you forgot to enter in button text using -ButtonRtext 'replaceMeWithText' \"\r\n            }\r\n\r\n            # To set the timer we'll need to create a timer but on the $Script level \r\n            if ($ButtonRcountdown) {\r\n                Write-Verbose \"Adding a countdown...\"\r\n                $ButtonText = $RightButton.Content\r\n                $Script:Timer = New-Object System.Windows.Forms.Timer\r\n                $Timer.Interval = 1000\r\n\r\n                Function Timer_Tick() {\r\n                    # Add text with countdown value in the button\r\n                    $RightButton.Content = \"$ButtonText ($Script:CountDown)\"\r\n                    --$Script:CountDown\r\n                    If ($Script:CountDown -lt 0) {\r\n                        $Script:Timer.Stop()\r\n                        # Once the timer is complete we'll send a click event\r\n                        $RightButton.RaiseEvent((New-Object -TypeName System.Windows.RoutedEventArgs -ArgumentList $([System.Windows.Controls.Button]::ClickEvent)))\r\n                        $Script:Timer.Dispose() \r\n                    }\r\n                }\r\n                $Script:CountDown = $ButtonRcountdown\r\n                $Script:Timer.Add_Tick({ Timer_Tick })\r\n                $Script:Timer.Start()\t\r\n            }\r\n\r\n            if ($ButtonRdefault) { $RightButton.IsDefault = $True }\r\n\r\n            $RightButton.Visibility = \"Visible\"\r\n\r\n            $RightButton.add_click(\r\n                {\r\n                    # I figured the actual button text would be more informative when looking back\r\n                    Write-Host \"$($RightButton.Content) Button Clicked!\"\r\n                    if ($buttonRaction) { Start-Process cmd.exe -ArgumentList \"\/c $buttonRaction\" -NoNewWindow }\r\n                    $window.Close()\r\n                }\r\n            )\r\n        }\r\n\r\n        if ($ButtonL -or $ButtonLtext) {\r\n            Write-Verbose \"Adding Left Button...\"\r\n\r\n            $LeftButton = $window.FindName(\"ButtonL\")\r\n\r\n            if ($ButtonLtext) { \r\n                Write-Verbose \"Adding Left Button Text...\"\r\n                $LeftButton.Content = $ButtonLtext \r\n            }\r\n            else {\r\n                Write-Warning \"It looks like you forgot to enter in button text using -ButtonLtext 'replaceMeWithText' \"\r\n            }\r\n\r\n            if ($ButtonLcountdown) {\r\n                Write-Verbose \"Adding Countdown...\"\r\n                $ButtonText = $LeftButton.Content\r\n                $Script:Timer = New-Object System.Windows.Forms.Timer\r\n                $Timer.Interval = 1000\r\n\r\n                Function Timer_Tick() {\r\n                    # Add text with countdown value in the button\r\n                    $LeftButton.Content = \"$ButtonText ($Script:CountDown)\"\r\n                    --$Script:CountDown\r\n                    If ($Script:CountDown -lt 0) {\r\n                        $Script:Timer.Stop()\r\n                        $LeftButton.RaiseEvent((New-Object -TypeName System.Windows.RoutedEventArgs -ArgumentList $([System.Windows.Controls.Button]::ClickEvent)))\r\n                        $Script:Timer.Dispose()\r\n                    }\r\n                }\r\n                $Script:CountDown = $ButtonLcountdown\r\n                $Script:Timer.Add_Tick({ Timer_Tick })\r\n                $Script:Timer.Start()\t\r\n            }\r\n\r\n            if ($ButtonLdefault) { $LeftButton.IsDefault = $True }\r\n            $LeftButton.Visibility = \"Visible\"\r\n\r\n            $LeftButton.add_click(\r\n                {\r\n                    Write-Host \"$($LeftButton.Content) Button Clicked!\"\r\n                    if ($buttonLaction) { Start-Process cmd.exe -ArgumentList \"\/c $buttonLaction\" -NoNewWindow }\r\n                    $window.Close()\r\n                }\r\n            )\r\n        }\r\n\r\n        # Actually displays the form here\r\n        $window.ShowDialog() | Out-Null\r\n    }\r\n\r\n    function Build-WinForm {\r\n        # Legacy Windows Form UI. It doesn't scale but looks similar to the one I built with WPF\r\n        Write-Verbose \"Legacy System Detected switching to windows forms...\"\r\n        Write-Verbose \"Building initial window...\"\r\n        $form = New-Object System.Windows.Forms.Form\r\n        $form.Height = 360\r\n        $form.Width = 350\r\n        $form.AutoSize = $false\r\n        $form.MaximizeBox = $False\r\n        $form.StartPosition = \"CenterScreen\"\r\n        $form.AutoScaleMode = [System.Windows.Forms.AutoScaleMode]::Dpi\r\n        if ($ApplicationID) { $form.Text = $ApplicationID }\r\n        if (-not $AllowResize) { $form.FormBorderStyle = \"FixedDialog\" }\r\n\r\n        Write-Verbose \"Setting window icon to $IconPath\"\r\n        if ($IconPath) {\r\n            $form.Icon = New-Object System.Drawing.Icon $IconPath\r\n        }\r\n        \r\n        Write-Verbose \"Building Logo...\"\r\n        $Logo = New-Object System.Windows.Forms.PictureBox\r\n        $Logo.Location = New-Object System.Drawing.Point(40, 25)\r\n        $Logo.Height = 125\r\n        $Logo.Width = 250\r\n        $Logo.BackColor = [System.Drawing.Color]::Transparent\r\n        $Logo.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::CenterImage\r\n        $Logo.ImageLocation = $LogoPath\r\n        $form.Controls.Add($Logo)\r\n\r\n        Write-Verbose \"Adding TextBox...\"\r\n        $TextBox = New-Object System.Windows.Forms.RichTextBox\r\n        $TextBox.Height = 75\r\n        $TextBox.Width = 275\r\n        $TextBox.Text = $Text\r\n        $TextBox.Font = \"Microsoft Sans Serif\"\r\n        $TextBox.ShowSelectionMargin = $False\r\n        $TextBox.Tabstop = $False\r\n        $TextBox.ReadOnly = $True\r\n        $TextBox.Location = New-Object System.Drawing.Point(30, 175)\r\n        $form.Controls.Add($TextBox)\r\n\r\n        Write-Verbose \"Adding Left Button...\"\r\n        $LeftFormButton = New-Object System.Windows.Forms.Button\r\n        $LeftFormButton.Location = New-Object System.Drawing.Point(30, 275)\r\n        $LeftFormButton.Height = 25\r\n        $LeftFormButton.Width = 114\r\n        $LeftFormButton.Font = \"Lucida Sans Unicode\"\r\n        if (-not $ButtonLtext) { $LeftFormButton.Text = \"Close\" }else { $LeftFormButton.Text = $ButtonLtext }\r\n        $LeftFormButton.Add_Click(\r\n            {\r\n                Write-Host \"$($LeftFormButton.Text) Button Clicked!\"\r\n                if ($buttonLaction) { Start-Process cmd.exe -ArgumentList \"\/c $buttonLaction\" -NoNewWindow }\r\n                $form.Close()\r\n            }\r\n        )\r\n        if ($ButtonLcountdown) {\r\n            $ButtonText = $LeftFormButton.Text\r\n            $Script:Timer = New-Object System.Windows.Forms.Timer\r\n            $Timer.Interval = 1000\r\n\r\n            Function Timer_Tick() {\r\n                # Add text with countdown value in the button\r\n                $LeftFormButton.Text = \"$ButtonText ($Script:CountDown)\"\r\n                --$Script:CountDown\r\n                If ($Script:CountDown -lt 0) {\r\n                    $Script:Timer.Stop(); \r\n                    $LeftFormButton.PerformClick();\r\n                    $Script:Timer.Dispose(); \r\n                }\r\n            }\r\n            $Script:CountDown = $ButtonLcountdown\r\n            $Script:Timer.Add_Tick({ Timer_Tick })\r\n            $Script:Timer.Start()\t\r\n        }\r\n        if ($ButtonL) { $form.Controls.Add($LeftFormButton) }\r\n\r\n        Write-Verbose \"Adding Right Button...\"\r\n        $RightFormButton = New-Object System.Windows.Forms.Button\r\n        $RightFormButton.Location = New-Object System.Drawing.Point(190, 275)\r\n        $RightFormButton.Height = 25\r\n        $RightFormButton.Width = 114\r\n        $RightFormButton.Font = \"Lucida Sans Unicode\"\r\n        if (-not $ButtonRtext) { $RightFormButton.Text = \"Accept\" }else { $RightFormButton.Text = $ButtonRtext }\r\n        $RightFormButton.Add_Click(\r\n            {\r\n                Write-Host \"$($RightFormButton.Text) Button Clicked!\"\r\n                if ($buttonRaction) { Start-Process cmd.exe -ArgumentList \"\/c $buttonRaction\" -NoNewWindow }\r\n                $form.Close()\r\n            }\r\n        )\r\n        if ($ButtonRcountdown) {\r\n            $ButtonText = $RightFormButton.Text\r\n            $Script:Timer = New-Object System.Windows.Forms.Timer\r\n            $Timer.Interval = 1000\r\n\r\n            Function Timer_Tick() {\r\n                # Add text with countdown value in the button\r\n                $RightFormButton.Text = \"$ButtonText ($Script:CountDown)\"\r\n                --$Script:CountDown\r\n                If ($Script:CountDown -lt 0) {\r\n                    $Script:Timer.Stop(); \r\n                    $RightFormButton.PerformClick();\r\n                    $Script:Timer.Dispose(); \r\n                }\r\n            }\r\n            $Script:CountDown = $ButtonRcountdown\r\n            $Script:Timer.Add_Tick({ Timer_Tick })\r\n            $Script:Timer.Start()\t\r\n        }\r\n        if ($ButtonR) { $form.Controls.Add($RightFormButton) }\r\n\r\n        $form.Add_Load(\r\n            {\r\n                $form.Activate()\r\n            }\r\n        )\r\n\r\n        Write-Verbose \"Displaying PopUp...\"\r\n        $form.ShowDialog() | Out-Null\r\n        $form.Dispose()\r\n    }\r\n\r\n    # If it was we'll error out and enform the technician they should run it as the \"Current Logged on User\"\r\n    if (Test-IsSystem) {\r\n        Write-Error \"This script does not work when ran as system. Use Run As: 'Current Logged on User'.\"\r\n        exit 1\r\n    }\r\n\r\n    # Windows Presentation Framework cannot be imported by PowerShell 2.0.\r\n    if ((Test-PSVersion) -lt 3) {\r\n        Write-Warning \"PowerShell 2 cannot import the presentation framework switching to winform...\"\r\n        $winForm = $True\r\n    }\r\n\r\n    # Inform the technician that having two simultaneous countdowns isn't really a good idea (it would technically work but doesn't really make sense)\r\n    if ($ButtonLcountdown -and $ButtonRcountdown) {\r\n        Write-Error \"[Error] -ButtonLcountdown and -ButtonRcountdown cannot be used at the same time!\"\r\n        exit 1\r\n    }\r\n\r\n    # Informing the technician that this doesn't make sense but I will allow it.\r\n    if ($ButtonRdefault -and $ButtonLdefault) {\r\n        Write-Warning \"Looks like you've made both buttons the default?\"\r\n    }\r\n\r\n    # If the technician forgot to set a button we'll set one.\r\n    if (-not $ButtonL -and ($ButtonLtext -or $ButtonLaction -or $ButtonLDefault -or $ButtonLcountdown)) { $ButtonL = $True }\r\n    if (-not $ButtonR -and ($ButtonRtext -or $ButtonRaction -or $ButtonRDefault -or $ButtonRcountdown)) { $ButtonR = $True }\r\n    \r\n    # If no default button was selected I'll pick for you.\r\n    if (-not $ButtonRDefault -and -not $ButtonLDefault) {\r\n        if ($ButtonL -and $ButtonR) { $ButtonRDefault = $True }\r\n        if ($ButtonL -and -not $ButtonR) { $ButtonLDefault = $True }\r\n        if ($ButtonR -and -not $ButtonL) { $ButtonRDefault = $True }\r\n    }\r\n\r\n    # This is where Send-UserPrompt (and the default notification system) store's the icon's path\r\n    $iconUri = Get-ItemProperty \"HKLM:SOFTWAREClassesAppUserModelId$($ApplicationId -replace 's+','.')\" -ErrorAction SilentlyContinue | Select-Object IconUri -ExpandProperty IconUri -ErrorAction SilentlyContinue\r\n    \r\n    # The base64 we set by default. If someone manually entered in their own base64 we'll prefer it over the application ID.\r\n    $defaultImg = \"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\n    if ($iconUri) {\r\n        Write-Host \"Application ID with Icon found! Checking if the icon and logo were supplied elsewhere...\"\r\n\r\n        if (-not $IconPath -and $IconBase64 -eq $defaultImg) {\r\n            Write-Host \"The icon was not specified elsewhere in the script switching from the default icon to the Applications Notification Icon.\"\r\n            $IconPath = $iconUri\r\n        }\r\n        else {\r\n            Write-Warning \"The icon was already specified either by script parameters or by replacing the default base64. Using that instead.\" \r\n        }\r\n\r\n        if (-not $LogoPath -and $LogoBase64 -eq $defaultImg) {\r\n            Write-Host \"The logo\/image was not specified elsewhere in the script switching from the default image to the Applications Notification Icon.\"\r\n            $LogoPath = $iconUri\r\n        }\r\n        else {\r\n            Write-Warning \"The Logo\/image was already specified either by script parameters or by replacing the default base64. Using that instead.\"\r\n        }\r\n    }\r\n\r\n    # An actual path to an image is prefered over the base64 encoding\r\n    if ($LogoBase64 -and -not $LogoPath) {\r\n        $LogoPath = \"$env:TEMPninjarmm-popup-logo.png\"\r\n        Write-Verbose \"Converting Logo base64 to image and saving to $LogoPath\"\r\n        ConvertFrom-Base64 -Base64 $LogoBase64 -Path $LogoPath\r\n    }\r\n\r\n    # Windows Forms and Wpf will follow a url for the logo but not the taskbar icon. We'll download it and then set the path for the rest of the script here.\r\n    if ($IconPath -match \"^http(.?):\/\/(.*)\") {\r\n        $IconPath = Invoke-Download -URL $IconPath -BaseName \"$env:TEMPninjarmm-popup-icon\"\r\n    }\r\n\r\n    # This will convert the base64 into an image and save it to the temp folder\r\n    if ($IconBase64 -and -not $IconPath) {\r\n        $IconPath = \"$env:TEMPninjarmm-popup-icon.png\"\r\n        Write-Verbose \"Converting Icon base64 to original image and saving to $IconPath...\"\r\n        ConvertFrom-Base64 -Base64 $IconBase64 -Path $IconPath\r\n    }\r\n\r\n    # An IconPath should now exist whether or not base64 was used or not. This will convert the image to a bitmap image and then into a usable icon\r\n    if ($IconPath) {\r\n        Write-Verbose \"Converting image to icon and saving to $env:TEMPninjarmm-popup-icon.ico ...\"\r\n        ConvertFrom-Image -ImagePath $IconPath -Path \"$env:TEMPninjarmm-popup-icon.ico\"\r\n        $IconPath = \"$env:TEMPninjarmm-popup-icon.ico\"\r\n    }\r\n}\r\nprocess {\r\n    # The -winForm parameter is both for testing purposes and for older os's\r\n    if (-not $winForm) {\r\n\r\n        # Time to start creating the form\r\n        Add-Type -AssemblyName PresentationFramework\r\n\r\n        # This section of code will error out when ran multiple times in the same session.\r\n        # This is because you can only enable dpi awareness prior to creating gui objects (DPI awareness should be preserved from the previous running).\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\r\n        \r\n        [System.Windows.Forms.Application]::EnableVisualStyles()\r\n        [System.Windows.Forms.Application]::SetCompatibleTextRenderingDefault($True)\r\n\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n        \r\n        Write-Verbose \"WPF imported successfully using WPF to display PopUp.\"\r\n        \r\n        Build-WPFform\r\n    }\r\n    else {\r\n        Build-WinForm\r\n    }\r\n\r\n    # To prevent the timer from sticking around after the script is done we'll stop it, dispose it and then set it as $null\r\n    Write-Verbose \"Cleaning up timer...\"\r\n    if ($ButtonRcountdown -or $ButtonLcountdown) {\r\n        $Script:Timer.Stop(); \r\n        $Script:Timer.Dispose();\r\n        $Script:Timer = $null\r\n        $Script:CountDown = $null\r\n    }\r\n}\r\nend {\r\n    \r\n    \r\n    \r\n}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Detalhamento<\/h2>\n<p><strong>Funcionalidade principal:<\/strong> O script usa o Windows Presentation Framework para vers\u00f5es modernas do Windows e volta para o Windows Forms para sistemas mais antigos, como o Windows 7 ou o Server 2008. Ele exibe um pop-up com op\u00e7\u00f5es personaliz\u00e1veis, como bot\u00f5es, cron\u00f4metros de contagem regressiva e texto personalizado.<\/p>\n<p><strong>Personaliza\u00e7\u00e3o e flexibilidade:<\/strong> O script oferece v\u00e1rios par\u00e2metros para personaliza\u00e7\u00e3o, incluindo texto, bot\u00f5es, a\u00e7\u00f5es para cada bot\u00e3o e cron\u00f4metros de contagem regressiva. Ele tamb\u00e9m permite o uso de imagens e \u00edcones personalizados, aprimorando a interface do usu\u00e1rio.<\/p>\n<p><strong>Codifica\u00e7\u00e3o Base64 para imagens:<\/strong> Um recurso inovador \u00e9 a capacidade de usar imagens codificadas em base64 para \u00edcones e logotipos, eliminando a necessidade de arquivos de imagem externos.<\/p>\n<p><strong>Vari\u00e1veis de ambiente e configura\u00e7\u00f5es padr\u00e3o:<\/strong> O script pode usar vari\u00e1veis de ambiente para configura\u00e7\u00f5es e padr\u00f5es, o que simplifica a implementa\u00e7\u00e3o em v\u00e1rios sistemas.<\/p>\n<h2>Casos de uso em potencial<\/h2>\n<p>Imagine um departamento de TI que precise lembrar centenas de usu\u00e1rios de reiniciar seus computadores ap\u00f3s uma atualiza\u00e7\u00e3o cr\u00edtica. Usando esse script, eles podem implementar uma mensagem pop-up com um cron\u00f4metro de contagem regressiva e um bot\u00e3o &#8220;Reiniciar agora&#8221;, minimizando a interrup\u00e7\u00e3o e garantindo a conformidade.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Os m\u00e9todos tradicionais, como notifica\u00e7\u00f5es por e-mail ou lembretes manuais, s\u00e3o menos eficazes e consomem mais tempo do que essa abordagem automatizada. Em compara\u00e7\u00e3o com ferramentas de terceiros, esse script oferece mais personaliza\u00e7\u00e3o e se integra perfeitamente aos fluxos de trabalho existentes do PowerShell.<\/p>\n<h2>Implica\u00e7\u00f5es<\/h2>\n<p>Embora esse script aprimore a comunica\u00e7\u00e3o e a conformidade do usu\u00e1rio, ele tamb\u00e9m traz a responsabilidade do uso adequado. O uso excessivo ou indevido pode levar \u00e0 fadiga de notifica\u00e7\u00f5es entre os usu\u00e1rios, reduzindo a efic\u00e1cia de alertas importantes.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Teste minuciosamente:<\/strong> Antes de uma implementa\u00e7\u00e3o generalizada, teste o script em um ambiente controlado.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Educa\u00e7\u00e3o do usu\u00e1rio:<\/strong> Informe os usu\u00e1rios sobre essas notifica\u00e7\u00f5es e sua import\u00e2ncia.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&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\"><strong>Atualiza\u00e7\u00e3o e manuten\u00e7\u00e3o:<\/strong> Atualize regularmente o script e garanta a compatibilidade com as novas vers\u00f5es do Windows.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No contexto dos MSPs e dos departamentos de TI, ferramentas como o NinjaOne podem se beneficiar muito com a integra\u00e7\u00e3o desses scripts do PowerShell. Ele simplifica os processos, garantindo uma comunica\u00e7\u00e3o eficiente e eficaz com o usu\u00e1rio, uma pedra angular do <a href=\"https:\/\/www.ninjaone.com\/pt-br\/gestao-ti-empresarial\/infraestrutura\/\">gerenciamento<\/a> moderno <a href=\"https:\/\/www.ninjaone.com\/pt-br\/gestao-ti-empresarial\/infraestrutura\/\">da infraestrutura de TI<\/a>. Esse script de mensagem pop-up do PowerShell exemplifica uma etapa em dire\u00e7\u00e3o a sistemas de TI mais interativos e responsivos, aumentando a produtividade e a conformidade em geral.<\/p>\n","protected":false},"author":35,"featured_media":193941,"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":[4212],"use_cases":[12460],"class_list":["post-815654","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/815654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=815654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/193941"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=815654"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=815654"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=815654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}