title: Remote execute powershell script that displays a form
body: <p>I am trying to run a powershell script remotely that displays a pop-up alert.  We are attempting to create a sort of "Emergency Notification System".  On the admin machine there is a script to choose which emergency alert to send to everyone, and then it should run/appear on everyone's screen.</p>
  
  <p>I've used the /msg command to achieve this, but the message is so plain that it doesn't catch the user's attention and the text can't be customized (unless it can be, which in that case PLEASE enlighten me).</p>
  
  <p>I am receiving the error below when attempting to do this.  I've also attempted to do it via PsExec but receive the same error.</p>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>Exception calling "ShowDialog" with "0" argument(s): "Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."</p>
  </blockquote>
  
  <p>Below is the PowerShell script.  It's nothing fancy, just wanting something that works for our purpose.</p>
  
  <pre><code>Add-Type -AssemblyName System.Windows.Forms
  $Form = New-Object system.Windows.Forms.Form
  $Form.Text = "Disaster Alert!"
  $Form.AutoScroll = $True
  $Form.AutoSize = $True
  $Form.AutoSizeMode = "GrowAndShrink"
  $Form.WindowState = "Normal"
  $Form.StartPosition = "CenterScreen"
  $Form.Font = New-Object System.Drawing.Font("Calibri",60,[System.Drawing.FontStyle]::Bold)
  
  $OKButton = New-Object System.Windows.Forms.Button
  $OKButton.Location = New-Object System.Drawing.Size(500,200)
  $OKButton.Size = New-Object System.Drawing.Size(75,23)
  $OKButton.Text = "Close"
  $OKButton.Font = New-Object System.Drawing.Font("Calibri",11)
  $OKButton.UseVisualStyleBackColor = $True
  $OKButton.Add_Click({$Form.Close()})
  $Form.Controls.Add($OKButton)
  
  $Label = New-Object System.Windows.Forms.Label
  $Label.Text = "Please Exit the Building`nBuilding Fire Alarm Sounding!!"
  $Label.ForeColor = "Red"
  $Label.TextAlign = "MiddleCenter"
  $Label.AutoSize = $True
  $Form.Controls.Add($Label)
  $Form.ShowDialog()
  </code></pre>
  
  <p>Is it possible to have a pop-up via PowerShell?  If not, does anyone have any recommendations?</p>
  
  <p>Thank you very much in advance.</p>