What is WPK (PowerShell Kit) ?

WPK,或Windows Presentation Foundation PowerShell Kit,是一个允许系统管理员和初学者通过构建用户界面简化复杂任务的PowerShell模块。它包含851个功能,能够帮助用户创建丰富的用户界面。本文介绍了如何使用WPK中的特定功能,如Show-SyntaxForCurrentCommand,并展示了一个使用WPK创建的GUI示例,展示了如何在界面上动态显示标签。

这里我要给大家介绍一下WPK,如标题所言,什么是WPK呢? 这里先引用一下WPK官方的一些介绍如下:

The Windows 7 Resource Kit companion CD includes many Windows PowerShell modules that you can use, but you might want to pay special attention to the WPK module.  WPK or the "Windows Presentation Foundation (WPF) PowerShell Kit," it enables you to use Windows PowerShell commands to create and display rich user interfaces.  With WPK, systems administrators and beginning scripters can make their jobs easier by building user interfaces to simplify complex tasks. 

 

WPK能让你非常简单方便的使用PowerShell实现友好界面,WPK被细分为很多模块,如果你直接导入WPK就可以使用目前851个function,当然也可以分别导入想要使用的模块,列表如下:

 

 

Module
Description
WPK
Create rich user interfaces quick and easily from Windows PowerShell.  Think HTA, but easy.  Over 600 scripts to help you build quick user interfaces
TaskScheduler
List scheduled tasks, create or delete tasks
FileSystem
Monitor files and folders, check for duplicate files, and check disk space
IsePack
Supercharge your scripting in the Integrated Scripting Environment with over 35 shortcuts
DotNet
Explore loaded types, find commands that can work with a type, and explore how you can use PowerShell, DotNet and COM together.
PSImageTools
Convert, rotate, scale, and crop images and get image metadata
PSRSS
Harness the FeedStore  from PowerShell
PSSystemTools
Get Operating System or Hardware Information
PSUserTools
Get the users on a system, check for elevation, and start-processaadministrator
PSCodeGen
Generates PowerShell scripts, C# code, and PInvoke
  

 

这里我用PowerShell ISE为大家演示下简单的操作
执行导入模块的cmdlet后,注意看菜单栏上就会增加显示一栏加载项选项,里面包含了一些实用的function,当然你也可以通过Get-Command -CommandType Function来显示所有有关加载WPK后可以调用的Function(注:有些Function在没加载WPK时就已存在)部分如下:
Function Add-ChildControl ...
Function Add-CodeGenerationRule ...
Function Add-CropFilter ...
Function Add-EventHandler ...
Function Add-ForeachStatement ...
Function Add-GridColumn ...
Function Add-GridRow ...
Function Add-IfStatement ...
Function Add-InlineHelp ...
Function Add-IseMenu ...
Function Add-OverlayFilter ...
Function Add-Parameter ...
Function Add-PInvoke ... 
                  

介绍一下加载项里的功能,比如Show-SyntaxForCurrentCommand功能在你选取你要显示使用语法的cmdlet后点击此功能就会显示该cmdlet的语法使用方法:

 

 

当然方法还有很多,这里我使用WPK里的2个function为大家演示一个在GUI上显示一串从小到大显示的label

 

执行结果如下:

 

 

是不是很有趣?如果你对很多function还不是很熟悉的话可以使用get-help查看下,当然给出的帮助内容并非十分详细,或许是因为function实在很多~ 期待WPK的更新改进。

 

最后PowerShellPack的下载地址为: PowerShellPack

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值