PowerShell Scripts, Tips, Expert Advices, Forums, and Resources

Geek Sync Live

Welcome to PowerShell.com, the educational and community site for Windows PowerShell People. Get a quick overview.

Latest Blog Posts

08-23-2016 - They’re Gone…
08-23-2016 - Display Windows
08-22-2016 - Add a Clock to PowerShell

As a Powershell.com member you will have access to:

  • Daily PowerShell tips written by Microsoft MVPs and other leading Windows PowerShell experts
  • Free Windows PowerShell advice and training provided by Microsoft MVPs and other leading Windows PowerShell experts
  • Access to leading Windows PowerShell blogs
  • A free ebook, Mastering PowerShell, written by Microsoft MVP Dr. Tobias Weltner
PowerTip of the Day

Display Windows

PowerShell 3+

It is fairly easy to use WPF (Windows Presentation Foundation) to create and show simple dialog windows in PowerShell. If you’d like to display a quick message, check this out:

Add-Type -AssemblyName PresentationFramework

$window = New-Object Windows.Window
$window.Title = 'Warning'
$window.WindowStartupLocation = 'CenterScreen'
$window.Topmost = $true
$TextBlock = New-Object System.Windows.Controls.TextBlock
$TextBlock.Text = 'You really should stop working and get some sunshine every now and then!'
$TextBlock.Margin = 20
$window.Content = $TextBlock
$window.SizeToContent = 'WidthAndHeight'
$null = $window.ShowDialog()

Twitter This Tip! ReTweet this Tip!

Copyright 2012 PowerShell.com. All rights reserved.