David Aiken is at it again. In his latest segment of the DFO show – Hosting Windows PowerShell Part 2, he converts the code he produced in Part 1 to use strong types by casting the PSObject.BaseObject. From there, he add the ability to select one the SERVICEs he displays and then to Stop it using the Stop-Service cmdlet. In Part 1, he showed how you can pass in a string and run it. Here he shows how you can create a Command object and programmatically add parameters to it and then execute that command in a pipeline.
He then shows how the program will break if the command or script you run tries to interact with the user (e.g. you specify –CONFIRM). The reason for this is that you need to implement the PSHost and PSHostInterface interfaces so that the scripts can interact with the user. David then shows you how to implement these interfaces to get a fully functional PowerShell GUI host.
I can’t want to see what he does in Part 3 (PowerShell in MMC).
Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx