If you want to display a dialog box / MessageBox from PowerShell rather than spitting out console text try this function:

function Show-MsgBox {
  param
  (
    [Parameter(Mandatory=$true)]
    [String]$Text,    
    [String]$Title = 'Message',    
    [String]
    $Icon = 'YesNo,Information'
  )

  Add-Type -AssemblyName 'Microsoft.VisualBasic' 
  [Microsoft.VisualBasic.Interaction]::MsgBox($text, $icon, $title)
}

Show-MsgBox -Text 'Reboot system?' -Title 'Warning' -Icon 'YesNoCancel,Question'

$result = Show-MsgBox -Text 'Reboot system?' -Title 'Warning' -Icon 'YesNoCancel,Question'
if ($result -eq 'Yes') {
  Restart-Computer -Force
}
facebooktwittergoogle_plusredditpinterestlinkedinmail