Powershell

As some know, I’m busy writing a book.  During the course of writing said book, I’ve come across a need to quickly look up the parameters for cmdlets and several particulars thereof. Such was the inspiration for my new favorite function: Get-Parameter. It goes like this:

PS > gpm Get-EventLog 

   ParameterSet: LogName 

Name         Type            IsMandatory Pipeline
----         ----            ----------- --------
LogName      String                 True    False
ComputerName String[]              False    False
Newest       Int32                 False    False
InstanceId   Int64[]               False    False
Index        Int32[]               False    False
EntryType    String[]              False    False
Source       String[]              False    False
Message      String                False    False
AsBaseObject SwitchParameter       False    False 

   ParameterSet: List 

Name         Type            IsMandatory Pipeline
----         ----            ----------- --------
ComputerName String[]              False    False
List         SwitchParameter       False    False
AsString     SwitchParameter       False    False

Now gpm is actually a meta-function which I created to customize the output for a particular need for my book.  Here’s what Get-Parameter looks like by default.

PS > Get-Parameter -Cmdlet Set-VM | Format-Table 

Name            Type            ParameterSet        IsMandatory       Pipeline
----            ----            ------------        -----------       --------
VM              VirtualMachine  DefaultSet                False           True
Name            String          DefaultSet                False          False
MemoryMB        Nullable`1      DefaultSet                False          False
NumCpu          Nullable`1      DefaultSet                False          False
GuestId         String          DefaultSet                False          False
AlternateGue... String          DefaultSet                False          False
OSCustomizat... OSCustomizat... DefaultSet                False          False
Server          VIServer[]      DefaultSet                False          False
RunAsync        SwitchParameter DefaultSet                False          False
Description     String          DefaultSet                False          False
VM              VirtualMachine  SnapshotSet               False           True
Name            String          SnapshotSet               False          False
Snapshot        Snapshot        SnapshotSet               False           True
OSCustomizat... OSCustomizat... SnapshotSet               False          False
Server          VIServer[]      SnapshotSet               False          False
RunAsync        SwitchParameter SnapshotSet               False          False

Instead of posting the code here, I’ve decided to start using the PoshCode script repository and its various evolving features.  So, you can find the code at the Get-Parameter listing.  Also, here is a direct download link.  Should open right in Notepad or however you’ve got that configured.

Update: I’ve updated the link to point to the latest version as of 12/21/08.

: http://halr9000.com/article/507

( Show All | Hide All ) Post a comment now » Sorry, the comments are closed.
2008-06-30 08:20:08

[...] Hal has a script up called Get-Parameter. [...]

2008-06-30 11:55:10

Hey Hal,

Nice script! I tweaked it a little to handle aliases (including aliases to aliases). (v.91)

- Oisin

2008-06-30 12:37:57

thanks dude, good work!

Sorry, the comment form is closed at this time.

  • Microblog

  • Recent Posts

  • Recent Comments

  • meta