A topic came up on the newsgroup today that I thought was a good segue into a series of posts that I’ve been working on. Paraphrased, the question was, “How do I get Monad to do stuff from another .Net language?” There are two ways to go about this, depending on the requirement. The first is to cleanly separate your object model from your cmdlet implementation. You write a class that does what you need it to.
I had a phone interview with Michael Brick at the New York Times a few weeks ago about the problems I (and others) have had with certain shady online camera dealers. His article on that just got printed, and it’s a good read. Especially interesting is the various official quotes that explain how difficult it is to solve the problem. Our collective internet rage takes place in a thought-based medium, where anything is possible.
The microsoft.public.windows.server.scripting newsgroup has really blossomed into a useful community for Monad users. When I post lengthy responses to the newsgroup, I very rarely post them to this blog as well. So the question is – how many of you do not read the newsgroup? Feel free to post your response in either email, or a comment below. If many of you read only the blogs, then I’ll start posting more entries based on newsgroup threads.
I’m rebuilding my computer, so I don’t have access to anything I have been planning to blog. So instead, I thought I’d write about something that is commonly considered difficult – but is actually quite within the reach of most of us. Adding a high-fidelity music input source to your car. If you have an MP3 player (or portable satellite receiver,) the first thing most people try is adding broadcasting the signal to their car stereo via an FM transmitter.
Howard van Rooijen, who works for Conchango, just posted a neat integration of CodeSmith, MSBuild, Monad and Windows Workflow for his company’s Community Day. We spoke about integrating MSBuild with Monad during the Hands on Labs at the PDC (and a few times since,) and it’s cool to see what’s come of his tinkering. His Congestion Charge Demo simulates London’s Vehicle Congestion Charging System – the automated system that charges a premium for driving within central London during peak hours.
Somebody is selling their gigantic 30 year vintage computer collection as a single lot on EBay. At several hundred collectible computers, and nearly as many manuals, this is a really nice trip down memory lane. Gotta get me one of those laptops!
In the last article, I introduced a library function to help you invoke inline C# from your scripts. Since we carefully profiled the burn-console script’s performance, we know exactly where to apply these inline performance optimizations: to the updateBuffer function, and the updateScreen function. The completed script is included below. The inline optimizations bring us to about 30 - 40 frames per second, easily fast enough to provide smooth animation.
In the last post, we got nearly as far as we could in improving the performance of our MSH script. We used the profiler to help target our performance optimizations. After we were finished, setting variables, incrementing counters, and comparing colour values took up the vast majority of our time. We can’t make these statements more efficient, nor can we execute them less frequently. To really push the performance of this script, we’ll write the highly critical sections using inline C#, rather than MSH.
The scripting guys continue to impart their magic scripting touch, now with a great big dose of MSH. Their “Scripting with the Microsoft Shell” Script Center went live recently, and it’s already chock-full of sample scripts – most applying the power of WMI interop. Their first article covers Accessing WMI From the Microsoft Shell – check it out! [Edit: Monad has now been renamed to Windows PowerShell. This script or discussion may require slight adjustments before it applies directly to newer builds.
The question came up on the newsgroup on how to monitor CPU usage in PowerShell. I wrote a script to demonstrate this some time ago with the intent to write about it – so now is probably an ideal time. The following poll-process script retrieves the process name, main window title, processor usage, disk activity, and working set. It continually refreshes the display to give you a task manager-like experience.