Hi,
Few days back I upload a script on “Powershell Digital Clock”, when i was writing that script at that time another script idea strike in to my mind, that ideas was to create a Stopwatch using Powershell.
I don’t know writing a script for stopwatch is a good idea or not, but i know one thing that i will learn a new thing and that may be helpful in the future.
After thinking i started writing an GUI based script to creating a stopwatch.
Powershell has open lots of possibilities for system administrators like me. We just need to imagine what we want and we able to achieve it easily using Powershell.
Last week when i take a session in Delhi User Group meeting, i told attendees that Powershell is the most easiest scripting language to be learn.
Anyway.
In this “Stopwatch” i used 4 buttons, one to start the clock, One to stop the clock , one to reset the stopwatch and another is for the lap.
I am not so good in designing GUI so ignore the colour of the buttons ;o).
Download Link : http://gallery.technet.microsoft.com/scriptcenter/Stopwatch-Powershell-Script-39cd5f26
In this script i learn few new things.
Lesson Learned:
-
System.Diagnostics.Stopwatch class
-
Few methods of System.Diagnostics.Stopwatch class
-
Make multiline textbox in powershell to auto scroll using
- $textBox1.SelectionStart = $textBox1.Text.Length;
$textBox1.ScrollToCaret()
- $textBox1.SelectionStart = $textBox1.Text.Length;
“Screenshot of the script”
Please run this script in –Sta mode
Download Link : http://gallery.technet.microsoft.com/scriptcenter/Stopwatch-Powershell-Script-39cd5f26
It doesn’t work though..
powershell -sta .\StopWatch-Community-Edition.ps1
You cannot call a method on a null-valued expression.
At .\StopWatch-Community-Edition.ps1:164 char:3
+ $stopWatch.Start()
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hi Herp,
Can you please download again and test it,?
thanks
aman
i get the same error. I’d love to see this working, any updates?
Hello. Thank you for sharing your script. I am getting the same error as above. How can I get this to work?