H9Labs

Introducing H9Labs PowerShell Cmdlets - Out-DataSet

 

The free and open source H9Labs PowerShell Cmdlets project consists of a series of PowerShell cmdlets created by the fine folks at H9Labs (that would be us), which we find useful and wanted to give back to the community. To that end, here are the H9Labs PowerShell Cmdlets!

Out-DataSet

Out-DataSet is an extremely useful and needed cmdlet. You can use it to pipe any type of data that can be formatted with the built-in cmdlet, Format-Table, into a typed Microsoft .NET System.Data.DataSet. This allows an unlimited manipulation of data that you simply cannot achieve with text globbing. This cmdlet is experimental in nature because it was achieved by reverse engineering the Format-Table cmdlet to pull the data directly from internal data structures that Microsoft does not expose via its public API. This was a necessary task in order to represent the data with 100% accuracy every single time.

Because the built-in cmdlet, Format-Table, is used to pre-process objects for a DataSet, an internal PowerShell runspace is created in order to execute the FT cmdlet. Internal PS runspace’s only load the built-in format schemas, not any other format schema files, which means that if your objects require an external format file for FT to work correctly, then you must use the Out-DataSet’s FormatSchemas parameter to pass that information in so it is loaded. By default the Out-DataSet cmdlet will attempt to load the VMware VI Toolkit’s format schema if it is available via the Registry.

Examples

Here are a few examples of using the Out-DataSet cmdlet.

Loading the Current Processes into a DataSet

   1:  PS C:\projects\h9labscmdlets> get-process | out-dataset
   2:   
   3:  RemotingFormat          : Xml
   4:  SchemaSerializationMode : IncludeSchema
   5:  CaseSensitive           : False
   6:  DefaultViewManager      : {System.Data.DataViewManagerListItemTypeDescriptor}
   7:  EnforceConstraints      : True
   8:  DataSetName             : DataSet
   9:  Namespace               :
  10:  Prefix                  :
  11:  ExtendedProperties      : {}
  12:  HasErrors               : False
  13:  IsInitialized           : True
  14:  Locale                  : en-US
  15:  Site                    :
  16:  Relations               : {}
  17:  Tables                  : {}
  18:  Container               :
  19:  DesignMode              : False

You can then print out the data set’s only table to see the information that was loaded.

   1:  PS C:\projects\h9labscmdlets> (get-process | out-dataset).Tables[0] | ft
   2:   
   3:       Handles       NPM(K)        PM(K)        WS(K)       VM(M)      CPU(s)          Id ProcessName
   4:       -------       ------        -----        -----       -----      ------          -- -----------
   5:           102            5         1116          232          32        0.17         372 alg
   6:           616            8         2872         3272          28      122.81         644 csrss
   7:            89            4          900         1620          29        4.56        2336 ctfmon
   8:          1616           81       242376        27408         855      313.03         336 devenv
   9:          1423           72       278244        25760         724       42.92        4008 devenv
  10:           411           10        12756         9444          71       72.75        1332 explorer
  11:           443           16        12584        11744          72       91.58        2356 explorer
  12:           291            8         3504         3176          51       14.78        2292 gnotify
  13:           114           35         9948          240          92        0.69        1552 H9WebServer
  14:            42            2          496          200          14         0.8        1780 HPZipm12
  15:             0            0            0           16           0                       0 Idle
  16:            32            2          612          396          28        1.05        2380 JetBrain...
  17:           249            7         4564          376          46        0.52        3276 jucheck
  18:            88            3          972           48          30        0.13        2168 jusched
  19:           412           10         4016          852          41       16.67         724 lsass
  20:           127            3          936          928          27        1.33        1640 mdm
  21:            93           34         2188         1024          37         6.3        1748 oodag
  22:            75            4         1464         1428          35        1.34        2324 oodtray
  23:           263            6        33548        25084         132        1.86         776 powershell
  24:           163            5         2396          336          44        0.33        2556 rapimgr
  25:           349           14        72856         2352         234           5         772 Reflector
  26:           510           31       356628       101800         572      184.61         816 Reflector
  27:           327            8         4352         1512          51         9.3         712 services
  28:            21            1          168           52           4        0.17         588 smss
  29:           156            6         4776         1744          47        1.31        1400 spoolsv
  30:           221            6         2740          512          60        0.55         900 svchost
  31:           326           13         2028         1568          33        1.69         972 svchost
  32:          1724           58        25968        16976         174      141.72        1056 svchost
  33:            78            3         1344         1004          29        1.98        1104 svchost
  34:           199            6         1700          684          36        0.63        1144 svchost
  35:           118            4         2460          164          36        0.27        1848 svchost
  36:          1160            0            0           44           2      666.22           4 System
  37:          1268           48       328172       102952        1159      149.22        1604 tomcat6
  38:           105            5         8792         6508          52       57.47        2100 TSVNCache
  39:            23            2          564           68          15        0.22         888 vmacthlp
  40:           210            4         1996         1784          37      536.94        1936 VMwareSe...
  41:            33            2          836          780          29        0.39        2200 VMwareTray
  42:           227            7        11188         5112          72       23.33        2248 VMwareUser
  43:           141            6         1300          508          45        0.66        2456 wcescomm
  44:           328            9         5072         2504          49        6.67         668 winlogon
  45:           259           39        16516          848         127         1.7        2532 Xenocode...

Would You Like to Know More?

You can read more about and download the H9Labs PowerShell Cmdlets project at its SourceForge project site, http://h9labscmdlets.sourceforge.net/.

 

Only published comments... Mar 27 2009, 02:46 PM by Schley Andrew Kutz

Comments

 

VMblog.com - Virtualization Technology News and Information for Everyone said:

Hyper9's Andrew Kutz and the H9Labs team has created a free and open source H9Labs PowerShell Cmdlets project which consists of a series of PowerShell cmdlets. Check out Out-DataSet: Out-DataSet is an extremely useful and needed cmdlet. You can use it

March 30, 2009 4:21 PM
 

» Binding SelectedValue from Dataset - C# c# Blog said:

Pingback from  » Binding SelectedValue from Dataset - C# c# Blog

May 12, 2009 9:49 PM

About Schley Andrew Kutz

Andrew Kutz is the walrus.

Bookmark and Share