This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
As with the switch from Monad to PowerShell there where some breaking changes, I have started a walk trough my blog history, and will re-do some of the scripts.
I will start with the first script on my blog :
MSH Object Viewer I posted this script also on the NG some time before, and got a great suprise when I did watch the second Channel 9 video with Jeffrey Snover :
MSHObjectViewer mentioned in More talking about Monad (links to all the channel 9 videos you can find in the $links section in the bottom of the blog)
The script will take a Object from the commandline (If you use the PowerShell Analyzer or VS it will look familiar ;-))
B.T.W. Karl did also update his MSH analyzer to PowerShell Analyzer, if you don't know this great PowerTool check out his blog Karl Prosser - Klumsy Geek
I did add the -noBase switch (but it seems not needed that often anymore)
and I did add a -array switch as I made the function also take pipeline input, I did rename it and fixed the Focus issue (for more info search for GUI in the blog), now you can use it like this
out-propertyGrid (get-date)
opg (LS)
opg (ls)[0] # shows first file / dir
ls | opg # shows last file (check the date editor ;-)
ls | opg -array # shows list
gwmi win32_operatingsystem | opg # note that you can browse in the Grid !
gwmi win32_share | opg -a
if you have a WMI Object in the PropertyGrid, try to open the properties, you get a nice list. Also try to change a date of a file you get a nice calendar.
the MSHObject (PsObject) was needed in the old beta as otherwise I did get the wrapperObject, so maybe its better to make the shitch called -PsObject and change it to $psObject.PsObject)
here is the Updated script :
# out-PropertyGrid.ps1
#
# 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.
#
# /\/\o\/\/ 2006
# http://mow001.blogspot.com
Function out-PropertyGrid {
Param ($Object,[switch]$noBase,[Switch]$array)
$PsObject = $null
if ($object) {
$PsObject = $object
}Else{
if ($Array.IsPresent) {
$PsObject = @()
$input |% {$PsObject += $_}
}Else{
$input |% {$PsObject = $_}
}
}
if ($PsObject){
$form = new-object Windows.Forms.Form
$form.Size = new-object Drawing.Size @(600,600)
$PG = new-object Windows.Forms.PropertyGrid
$PG.Dock = 'Fill'
$form.text = "$psObject"
if ($noBase.IsPresent) {"no";
$PG.selectedobject = $psObject
}Else{
$PG.selectedobject = $psObject.PsObject.baseobject
}
$form.Controls.Add($PG)
$Form.Add_Shown({$form.Activate()})
$form.showdialog()
}
}
if (!(get-command -ea SilentlyContinue opg)) {set-alias opg out-PropertyGrid}
Enjoy,
Greetings /\/\o\/\/
Tags : Monad msh PowerShell