Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

video of first PowerShell virtual user group with my PowerTab introduction online

Marco Shaw , Posted the "draft version" of the LiveMeeting session : PowerShell Virtual User Group- video from meeting #1--VIDEO ONLINE there are 2 part's in WMV format 3 + 13 MB the first file is the introduction and the latter contains the 3 sessions.

As you could see in my last post : How to do a demo in Livemeeting , I had a lot of Problems Challenges, before and during my PowerTab Demo, but watching it back was not as bad as I feared, and I think overall this First PowerShell virtual user group, apart from some other small "1.0 bugs" was a big success, it was very informational, Marco did a good job presenting and Keith and Ivan both gave a great session, I had and exiting but fun time as a guest speaker and look forward to attend the future meetings !

If you did miss this session and looking for be sure to watch the video ! (I hope Marco does manage to repost it in a bit better quality, see his blogpost )

For my session I think while a bit messy it still gives a good introduction into what PowerTab can do and some of the accidents even gave me a big laugh especially this one : 

Export-TabExpansiontheme

As a viewer you can see it coming that long before by just reading the command , as I say that I'm going to import a theme and then start using the export-TabexpansionTheme function ;-)

And the other big accident might have a positive side also for pointing out some interesting facts about PowerTab Showing of one of the concepts I did play with while developing PowerTab Using Custom Build objects as an interface by creating script properties and methods, if you are a bit more used to PowerShell already it might be a nice part of the code to look at.

I will try to explain where I did go wrong in the beginning of the Demo, as this exposes a very interesting part if the inner workings of the PowerTab Configuration : 

 

why did the import-Tabexpansion Function not work and did I have to start a new shell ?

With the command :

$PowertabConfig.colors = 'Groen'

I did overwrite the Color Functionality by setting the Colors Container and not an individual Property, that had a bigger effect as you might think at first.In first instance I also did think I could solve this by a Simple import-TabexpansionConfig but the following console session shows why this did not work :

 

[PoSH]> $PowertabConfig.Colors


BorderColor : Blue
BorderBackColor : DarkBlue
BackColor : DarkGray
TextColor : Yellow
SelectedBackColor : DarkRed
SelectedTextColor : Red
BorderTextColor : Yellow
FilterColor : DarkGray



[PoSH]> $PowerTabConfig.Colors | gm


TypeName: System.Object

Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ExportTheme ScriptMethod System.Object ExportTheme();
ImportTheme ScriptMethod System.Object ImportTheme();
ToString ScriptMethod System.Object ToString();
BackColor ScriptProperty System.Object BackColor {get=$dsTabExpansion.Tables['Config'].Select("Name = 'BackC...
BorderBackColor ScriptProperty System.Object BorderBackColor {get=$dsTabExpansion.Tables['Config'].Select("Name = ...
BorderColor ScriptProperty System.Object BorderColor {get=$dsTabExpansion.Tables['Config'].Select("Name = 'Bor...
BorderTextColor ScriptProperty System.Object BorderTextColor {get=$dsTabExpansion.Tables['Config'].Select("Name = ...
FilterColor ScriptProperty System.Object FilterColor {get=$dsTabExpansion.Tables['Config'].Select("Name = 'Fil...
SelectedBackColor ScriptProperty System.Object SelectedBackColor {get=$dsTabExpansion.Tables['Config'].Select("Name ...
SelectedTextColor ScriptProperty System.Object SelectedTextColor {get=$dsTabExpansion.Tables['Config'].Select("Name ...
TextColor ScriptProperty System.Object TextColor {get=$dsTabExpansion.Tables['Config'].Select("Name = 'TextC...


[PoSH]> $PowerTabConfig.Colors | gm -Name backcolor | fl


TypeName : System.Object
Name : BackColor
MemberType : ScriptProperty
Definition : System.Object BackColor {get=$dsTabExpansion.Tables['Config'].Select("Name = 'BackColor'")[0].Value;set=tr
ap{write-warning $_;continue}
$dsTabExpansion.Tables['Config'].Select("Name = 'BackColor'")[0].Value = [consolecolor]$ar
gs[0];}



[PoSH]>

 

 You can see that the Colors Property of $PowerTabConfig is actually an Object itself and each of the colors is represented by a script property that contains a PowerShell script to set and to get a value in the configuration datatable ,  so it is actually an Interface to the database.So by overwriting this object with the String 'Groen' (Green in Dutch a mistake actually on purpose as you can see later in the session.) I mess up the Object for accessing the configuration not the actual configuration it self)

I can reload the Configuration database but as I did overwrite the interface to it this did not works and the example below will show why using the function did not work also :

[PoSH]> Get-Content function:\Import-TabExpansiontheme
param($path) $theme = Import-Csv $path
$PowerTabConfig.Colors.ImportTheme($theme)

[PoSH]> $PowerTabConfig.Colors.ImportTheme


Script : $args[0] |% {$PowerTabConfig.Colors."$($_.name)" = $_.Color}
OverloadDefinitions : {System.Object ImportTheme();}
MemberType : ScriptMethod
TypeNameOfValue : System.Object
Value : System.Object ImportTheme();
Name : ImportTheme
IsInstance : True



[PoSH]>

You can see that the  Import-TabExpansiontheme function is simply a wrapper for the $PowerTabConfig.Colors.ImportTheme($theme) Method (that I did overwrite also ;-) ) , and this Method again is a wrapper as you can see above for a simple PowerSHell script again :

$args[0] |% {$PowerTabConfig.Colors."$($_.name)" = $_.Color}

The $powerTabConfig object is actualy build by the Initialize-Tabexpansion.ps1 Script that is called in the Profile and that is also nice to take a look at for an example how to create custom objects in PowerShell.

 

I'm kinda busy at the moment but will try to do some of the other promised follow-up posts over the weekend

 

Enjoy,

Greetings /\/\o\/\/

Published Thursday, October 11, 2007 5:53 PM by MoW

Comments

# Interesting Finds: October 12, 2007

Friday, October 12, 2007 10:19 AM by Jason Haley
Anonymous comments are disabled