/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" CodeSigning in Monad" Shell Beta 2 (for .NET Frame... "," WMI viewer script for MSH (GUI) "," Monad Release for Whidbey RTM "," Thow Dices in MSH "," when to change your clock ? ask Monad !! "," AD Infastructure exploring with MSH "," Get Current dir in MSH consoleTtitle "," MSH ASCII translator "," red MSH> prompt "," Monad presentation on PDC05 available, "," ")

Monday, October 31, 2005


Strange behavour of get-member on DataTables

When working on the get_WMIdatagrid

See : WMI viewer script for MSH (GUI)

I noticed some strange behavour of Get-Member :

Get-Member will not show me DataTables or collections.
how do I look at there methods and properties?
as you can see in the example below that MSH will not even give me A get Member on a DataTable (say's I have no Object, but as you see I can work with it only I can't see wat I'm doing ;-()

That is Till I add a Datarows to it
then it will not give me the dataRowCollection but a dataRow,
that's 3 levels deeper than tat I asked for !

( DataTable -> DataRowCollection -> DataRow )

$dt = new-object system.data.datatable

if you try this in the MSH Object Viewer


it WILL work !

I recently noticed that this works also :

MSH G:\Monad> new-object system.data.dataTable  gm

TypeName: System.Data.DataTable

Name MemberType Definition
---- ---------- ----------
AcceptChanges Method System.Void AcceptChanges()
add_ColumnChanged Method System.Void add_ColumnChanged(DataColumnChangeEventHandler value)

But ofcourse this is not handy while working.
this has cost me a lot of time while testing.

gr /\/\o\/\/

PS I posted this in the NG also if I hear something about i I will post again.
*Edit* I got an asnwer : See Create System Variable From MSH (Part2)

MSH > $dt = new-object system.data.datatable
MSH > $dt
MSH > $dt gm
get-member : No object has been specified to get-member.
At line:1 char:8

MSH > $DT.TableName = "test"
MSH > $dt
MSH > $dt.tablename

MSH > $dt gm
get-member : No object has been specified to get-member.
At line:1 char:8

MSH > $Col = new-object System.Data.DataColumn
MSH > $Col.ColumnName = "col1"
MSH > $DT.Columns.Add($Col)

MSH > $Col = new-object System.Data.DataColumn
MSH > $Col.ColumnName = "col2"
MSH > $DT.Columns.Add($Col)

MSH > $dt.columns

MSH > $dt.columns gm

TypeName: System.Data.DataColumn

Name MemberType Definition
---- ---------- ----------

MSH > $dt gm
get-member : No object has been specified to get-member.
At line:1 char:8

MSH > $dr = $dt.newrow()
MSH > $dr.col1 = "val1"
MSH > $dr.col2 = "1"

MSH > $dr = $dt.newrow()
MSH > $dr.col1 = "val2"
MSH > $dr.col2 = "2"
MSH > $DT.Rows.Add($DR)

MSH > $dt gm

TypeName: System.Data.DataRow

$MC = new-object system.management.ManagementClass win32_share
$MOC = $MC.GetInstances()
$MOC foreach {
$null = "Trap Me Please"
trap{"Trap";$null[$null] = "Find Me Please"}

Comments: Post a Comment

Links to this post:

Create a Link

<< Home


October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?