{"id":17644,"date":"2007-06-27T11:45:37","date_gmt":"2007-06-27T19:45:37","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17644"},"modified":"2019-05-16T11:50:33","modified_gmt":"2019-05-16T19:50:33","slug":"hosting-windows-powershell-part-2-of-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/hosting-windows-powershell-part-2-of-3\/","title":{"rendered":"Hosting Windows PowerShell Part 2 of 3"},"content":{"rendered":"<p>David Aiken is at it again. In his latest segment of the DFO show \u2013 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.\nHe then shows how the program will break if the command or script you run tries to interact with the user (e.g. you specify \u2013CONFIRM). 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.\nGreat stuff!\nI can&#8217;t want to see what he does in Part 3 (PowerShell in MMC).\nJeffrey Snover [MSFT]\nWindows Management Partner Architect\nVisit the Windows PowerShell Team blog at: http:\/\/blogs.msdn.com\/PowerShell\nVisit the Windows PowerShell ScriptCenter at: http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>David Aiken is at it again. In his latest segment of the DFO show \u2013 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 [&hellip;]<\/p>\n","protected":false},"author":685,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17644","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>David Aiken is at it again. In his latest segment of the DFO show \u2013 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/685"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17644"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17644\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}