图形界面的 PowerShell 脚本

来源:互联网 发布:java飞机大战源码 编辑:程序博客网 时间:2024/05/22 06:41

WSH 环境下,对于VBS 脚本,既有cscript 也有 wscript,VBS 脚本很容易有一些简单的界面,例如message box, input box 等。 PowerShell 脚本呢?

SAPIEN 的 PrimalForms  (和大名鼎鼎的 PrimalScript 系出同门啊)可以把 PowerShell 脚本转化为 GUI 的 Windows form 程序,呵呵。http://www.sapien.com/blog/2012/01/24/convert-powershell-scripts-to-gui-applications/

不只是转化,PrimalForms本身就是PowerShell 集成开发环境,也就是说用这个工具开发出来的 windows form 程序本身就是一个 PowerShell 脚本,这里有一个简单的guide,关于如何操作,TechNet 脚本中心的文档http://blogs.technet.com/b/heyscriptingguy/archive/2010/02/28/hey-scripting-guy-february-28-2010.aspx,很酷啊。

借助Windows form, 当然可以直接编写出GUI 界面,MS有文档 http://technet.microsoft.com/en-us/library/ff730941.aspx,但是既然有如此方便的工具,何苦这么麻烦。  这里还有一篇是用PowerShell 通过HTA来显示GUI的,http://social.technet.microsoft.com/wiki/contents/articles/2166.how-to-add-a-graphical-user-interface-to-a-powershell-script-by-using-html-applications-en-us.aspx功能上当然都可以做到,但是这样不够酷,呵呵。 比较专业级的,MS PowerShell team当然也有提供方法http://stackoverflow.com/questions/1705580/framework-for-gui-on-top-of-powershell

 

VMware 给vSphere也装备了 PowerCLI,MS给Hyper-V也提供了 PowerShell module, 加上基于.net framework 的无限扩展性,PS现在影响力越来越大,确实值得深入学习。PowerShell 的集成开发环境,除了PowerShell ISE,比较常见的 PowerShell GUI,PowerShell plus,名气最大的就是 PrimalScript了,不过它过于强大,不只是支持PowerShell而已。

相关资源: cmdlet & help designer  http://cmdletdesigner.codeplex.com/sourcecontrol/list/changesets?ProjectName=cmdletdesigner