Hosting Windows PowerShell Part 2 of 3

Hosting Windows PowerShell Part 2 of 3

  • Comments 1

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.

Great stuff!

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

 

Leave a Comment
  • Please add 2 and 1 and type the answer here:
  • Post
  • Interesting, he demos a recast to a base object.  Could we use that same trick to recast an "adapted" ADSI object back into a straight DirectoryServices object in order to get rid of the annoying ".psbase" mentions everywhere?  Could this recasting trick be used to get rid of ".psbase" with different interfaces generally?  Hmmmm....  

Page 1 of 1 (1 items)