Sometimes I want a script to run automatically, but still prompt me before it takes an action. A neat way of doing this is with a pop up message box. Utilizing the MessageBox class from the .NET Framework, we can do just that. For example, maybe I have a script that notifies me with the Dow Jones Industrial Average drops by 300 points in the current trading session. Hey, that is a money making opportunity! 1 2 3 4 5 6 [ System.Reflection.Assembly ]:: LoadWithPartialName( "System.Windows.Forms" ) $Answer = [ Windows.Forms.MessageBox ]:: Show( "DJIA has dropped by 300 points today `n Do you want to `n go to your IRA?" , "Trade Alert" , [ Windows.Forms.MessageBoxButtons ]:: YESNO , [ Windows.Forms.MessageBoxIcon ]:: Information) If ( $Answer -eq "Yes" ) { Write-Host "Do Something." } Essentially, line 1 gives us access to the Windows Forms objects. Line
Welcome to the blogsite of MCTExpert. I am a Microsoft Certified Trainer. Here you will find the real questions that are asked to me by my students.