/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" Windows "Monad" Shell Beta 2 Documentation Pack "," sample of mine used at reskit.net "," Another Channel9 Interview With Jeffrey Snover. "," /\/\o\/\/ first entry "," ")

Thursday, October 20, 2005


MSH Object Viewer

Fuction to see/Change members of Objects in a Gui.
(a bit as get-member does on the Commandline)

it is a great help exploring MSH for me

some examples of usage :

ov (gi test.txt) -> file properties

ov(new-object system.management.managementclass)<- you can change class from GUI so this is giving you a WMI browser. Look at the difference between the following commands !: (in the latter you don't see the methods, and MSH is taking the instance already) ov(new-object system.management.managementclass("win32_operatingsystem")) ov (get-wmiObject win32_operatingSystem) ov(gps[0]) -> info of first process
ov ($var) -> Info on variable.
ov(dir) -> dir in GUI

gr /\/\o\/\/

# will show an Object in a PropertyGrid (propertywindow in Visual Studio)
# this is an easy way to look at MSH objects.
# you can read / write the object properties.
# and it has some nice editors for some properties
# eg. ov (gi test.txt)will let you change the date by a calendarview
# /\/\o\/\/ 2005


function ObjectViewer {
$form = new-object "System.Windows.Forms.Form"
$form.Size = new-object System.Drawing.Size @(600,600)
$PG = new-object "System.Windows.Forms.PropertyGrid"
$PG.Dock = [System.Windows.Forms.DockStyle]::Fill
$form.text = "$args"
$PG.selectedobject = $args[0].mshObject.baseobject
$form.topmost = $true
set-Alias OV ObjectViewer 

Anonymous Anonymous
Nice script. Just one question: shouldn't you set the scope of the function to global? And i think that you also need to set the scope for the set-alias cmdlet. am i wrong here? thanks.
Blogger /\/\o\/\/
you can also start the script dotsourced, like this :

. .\Objectviewer.msh

I did think I mentioned somewhere but not in this post.

this loads the whole script in the Global scope,thats the way I have it in my profile.

but you can also set the scope of the function to global as you mentioned.

the way I use often also, is just pasting the code in the MSH Console, this will get the function in the global scope also.

I mostly leave it to the user, but in this case only declaring a function in a subscope makes not much sense indeed, but if you use it as a subfunction in a script, loading global would not be wanted.

I think it's better to fail and than think, oops I have to dot-source this, as messing up your global scope without realising.

for more info try searching my blog for "tuning profile"

thanks for the Comment

gr /\/\o\/\/
Post a Comment

<< 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?