Introducing the Windows 7 Resource Kit PowerShell Pack

Introducing the Windows 7 Resource Kit PowerShell Pack

  • Comments 19

Since I work on the PowerShell team, I’ve been lucky enough to get a couple of years jump start on producing PowerShell V2 scripts and modules.  With every new script I write in V2 I get more and more amazed by the possibilities in PowerShell.  I’ve discovered how to do many cool things that, as some of my colleagues outside of the PowerShell team have put it, have showed them the Power of PowerShell.

At each CTP of PowerShell, I’ve tried to share this power of PowerShell here on this blog.  Thanks to Mitch Tulloch (the main author of the Windows 7 Resource Kit) and Ed Wilson (the Scripting Guy), I was able to collect some of my V2 modules for the companion CD of the resource kit.  This collection of scripts became know as the Windows 7 Resource Kit PowerShell Pack.

Today, the Windows 7 Resource Kit should be available in stores, and the PowerShell Pack is available for download on code gallery.

The PowerShell Pack contains over 800 scripts in 10 different modules.  Here’s a brief overview:

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.  To get started learning how to write rich WPF UIs in script, check out Writing User Interfaces with WPK.

IsePack
Supercharge your scripting in the Integrated Scripting Environment with over 35 shortcuts.

TaskScheduler
List scheduled tasks, create or delete tasks

FileSystem
Monitor files and folders, check for duplicate files, and check disk space

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 P/Invoke

I’ll be posting a lot more about these modules in the next weeks, both here and on Channel9, but you can start exploring the modules now by checking out the PowerShellPack on code gallery.  I will also be tweeting some cool tidbits about the PowerShell Pack under the tags: #PowerShellPack, #WPK and #IsePack

I’ll also be on Hal Rotenberg’s PowerScripting Podcast tonight talking about the PowerShell Pack.

Hope this helps,

James Brundage [MSFT]

Quick Note: The MSI was updated at ~ 4:30pm on day of release. If you downloaded it before this time, please download the MSI again.

Leave a Comment
  • Please add 5 and 6 and type the answer here:
  • Post
  • That's great!

    I am having one issue when running Import-Module PowerShellPack

    You cannot call a method on a null-valued expression.

    At C:\Users\username\Documents\WindowsPowerShell\Modules\IsePack\Add-IseMenu.ps1:90 char:47

    +                     $m = $iseMenu.Submenus.Add <<<< ($itemName, $scriptBlock, $_.ShortcutKey)

       + CategoryInfo          : InvalidOperation: (Add:String) [], RuntimeException

       + FullyQualifiedErrorId : InvokeMethodOnNull

    I am running Win 7 Pro 64bit. Any Ideas?

  • Great stuff! Looking forward to getting into it.

  • Brian.  The issue you indicated was a slight bug in the produced MSI.  This was the update I uploaded @ ~4:30 PM PST.  It should be working fine now.

    James

  • PS C:\> $h = Get-Help *

    PS C:\> $h.Count

    471

    PS C:\> Import-Module wpk

    PS C:\> $hh = Get-Help *

    PS C:\> $hh.Count

    471

    PS C:\> $hl = Get-Help New-Label

    PS C:\> $hl.Synopsis

    Creates a new System.Windows.Controls.Label

    - Why 'get-help *' is not work for WPK module?

  • I re-downloaded the msi, the amount of errors is greatly reduced but I did receive:

    Add-Type : c:\Users\JKav\AppData\Local\Temp\neohef_v.0.cs(4) : { expected

    c:\Users\JKav\AppData\Local\Temp\neohef_v.0.cs(3) :

    c:\Users\JKav\AppData\Local\Temp\neohef_v.0.cs(4) : >>> namespace SystemMetrics0.609978667278764

    c:\Users\JKav\AppData\Local\Temp\neohef_v.0.cs(5) : {

    At C:\Users\JKav\Documents\WindowsPowerShell\Modules\PSSystemTools\PSSystemTools.psm1:2 char:33

    + $script:systemMetrics = Add-Type <<<<  -Name SystemMetrics `

       + CategoryInfo          : InvalidData: (c:\Users\JKav\A...514: { expected:CompilerError) [Add-Type], Exception

       + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand

    Add-Type : Cannot add type. There were compilation errors.

    At C:\Users\JKav\Documents\WindowsPowerShell\Modules\PSSystemTools\PSSystemTools.psm1:2 char:33

    + $script:systemMetrics = Add-Type <<<<  -Name SystemMetrics `

       + CategoryInfo          : InvalidData: (:) [Add-Type], InvalidOperationException

       + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand

  • I had the same "{ expected..." error when importing pssystemtools. In my case PSCX 1.2 is the culprit. It also has a get-random cmdlet. The Powershell get-random generates an Int32 while the PSCX version produces a double.

    As a workaround I changed this line in PSSystemTools.psm1

    $script:RandomNamespace = "SystemMetrics$(Get-Random)"

    to

    $script:RandomNamespace = "SystemMetrics$(Microsoft.PowerShell.Utility\Get-Random)"

    PSCX should start using prefixes :-)

  • Thanks, I re-downloaded the MSI and it worked fine.

  • James - this is great!  I was just about to start using Powerboots but I guess this will be the way to go for now...

    I'm struggling with some XAML control elements that don't appear to be present or don't translate on the New-* cmdlets, specifically how do I use "Width=Auto" and "LastChildFill=True" (ie. the XAML would  be "<DockPanel Width="Auto" Height="Auto" LastChildFill="True">")?

    New-DockPanel seems to choke on "-Width 'Auto'" or on "-LastChildFill 'True'".

    Thanks - this is going to be fun!

    Chris

  • Thank you James,

    for IsePack.

    There are a lot of fine functions in IsePack.

    And I think you give a goog example for coding style of the individual functions.

    That will help me a lot rewriting some of the functions in Ise-Cream http://www.codeplex.com/psisecream.

    It is important to find easy ways, so that anyone can merge Ise-Extensions from different sources into his profile.

    In the long run, we need a standard way helping to individually configure the add-ons menu, especialy the hot-keys.

    Bernd Kriszio

    [twitter @bernd_k]

  • This is obviously intended for Windows 7, but will it work in previous versions of Windows with Powershell v2 installed?

  • There seems to be a bug (typo really) in the get-OSVersion cmdlet, that causes Windows Server 2003 to be reported incorrectly.  The definition of the cmdlet shows this logic:

    -----------------------------------------

    $os = Get-WmiObject Win32_OperatingSystem -computerName $computer -Impersonation Impersonate -Authentication PacketPriv

    acy

       if ($detailed) { return $os }

       Switch -regex ($os.Version)

       {

           "5.1.2600" { "Windows XP" }

           "5.1.3790" { "Windows Server 2003" }

           "6.0.6001" {

               if ($os.ProductType -eq 1) {

                   "Windows Vista"

               } else {

                   "Windows Server 2008"

               }

           }

           "6.1."    { "Windows 7" }

           DEFAULT { Throw "Version not listed" }

       }

    ------------------------------------------

    However, "Windows Server 2003" should be matched to "5.2.3790", not "5.1.3790".

    Thanks to the whole team - these are wonderful.

  • Random Crashes.

    Is anyone else trying to use WPK?  I've been developing a UI front end for an application and it's really easy to use.  Excellent.

    BUT.  No matter how simple the WPF, it seems once I've imported the WPK module that after some time (between 15-45mins) calling a WPK New-* cmdlet will crash the PowerShell host (whether it's the standard console host, ISE or PowerShell Plus).

    This is VERY frustrating and unless fixed it means my application will never be useable.  Can anyone else repro?  I've got a very standard (recently installed) Win 7 Ultimate release version, 64-bit.  Have the same issue on my laptop - Win 7 release version 32-bit.

    Application eventlog error 1000 (this one's for ISE but I have LOTS of others...)

    Faulting application name: PowerShell_ISE.exe, version: 6.1.7600.16385, time stamp: 0x4a5ba920

    Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdfe0

    Exception code: 0xc000041d

    Fault offset: 0x000000000000aa7d

    Faulting process id: 0x1a28

    Faulting application start time: 0x01ca55618f97f5f8

    Faulting application path: C:\Windows\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe

    Faulting module path: C:\Windows\system32\KERNELBASE.dll

    Report Id: 57a3555f-c168-11de-88c0-0015589b6a1b

    Followed by event 1001:

    Fault bucket , type 0

    Event Name: APPCRASH

    Response: Not available

    Cab Id: 0

    Problem signature:

    P1: PowerShell_ISE.exe

    P2: 6.1.7600.16385

    P3: 4a5ba920

    P4: KERNELBASE.dll

    P5: 6.1.7600.16385

    P6: 4a5bdfe0

    P7: c000041d

    P8: 000000000000aa7d

    P9:

    P10:

    Attached files:

    C:\Users\chris\AppData\Local\Temp\WERA65A.tmp.WERInternalMetadata.xml

    These files may be available here:

    C:\Users\chris\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_PowerShell_ISE.e_32816bd647a0eca648546f5eac301673d195cb3_0915ac27

    Analysis symbol:

    Rechecking for solution: 0

    Report Id: 57a3555f-c168-11de-88c0-0015589b6a1b

    Report Status: 17

    Thanks all.

    Chris

  • Will this pack work on Vista and XP? Or the new scripts are applicable only to Windows 7?

  • Would like to see the answer to that last question: will it work on Vista & XP?

    Just tried it w/XP and the import-module cmd generated lots of errors.

  • Would like to see the answer to that last question: will it work on Vista & XP?

    Just tried it w/XP and the import-module cmd generated lots of errors.

Page 1 of 2 (19 items) 12