en-us/about_PSTeachingTools.help.txt

TOPIC
    about_PSTeachingTools
 
SHORT DESCRIPTION
    The PSTeachingTools module is designed to offer a set of PowerShell commands
    that can be used to demonstrate and teach PowerShell fundamentals.
 
LONG DESCRIPTION
    Very often, PowerShell teachers use out-of-the-box cmdlets like Get-Process
    and Get-Service to demonstrate concepts and techniques. However, sometimes
    the commands themselves or their output might be distracting. This module
    contains a set of commands based on a more neutral and non-technical noun,
    a vegetable.
 
    The *-Vegetable commands are designed to be combined in pipelined
    expressions like regular PowerShell commands. These demonstration commands
    also write objects to the pipeline. The custom objects have a corresponding
    custom format.ps1xml file, which displays results in a formatted table. Many
    PowerShell commands, like Get-Service use this same technique. The concept
    behind these demonstration commands is that once students see how vegetable
    objects can be used, consumed and manipulated in PowerShell, the same
    concepts and techniques can be applied to service, process, or any other
    object type in PowerShell.
 
    For advanced classes, you can use the module files themselves to teach
    concepts as module development, advanced functions, PowerShell classes,
    working with JSON and CSV files, and format.ps1xml files.
 
EXAMPLES
    The Get-Vegetable command is designed to demonstrate how PowerShell works
    and how you can work with PowerShell. Once the student understands how this
    command works, they should be able to apply the concepts to any other
    command.
 
    PS C:\> Get-Vegetable
 
    UPC Count Name State Color
    --- ----- ---- ----- -----
    4078 12 corn Roasted yellow
    4064 4 tomato Raw red
    4062 11 cucumber Raw green
    4562 10 carrot Raw orange
    4089 13 radish Raw red
    4674 14 peas Steamed green
    4811 12 turnip Boiled purple
    4725 18 russet potato Fried brown
    4060 15 broccoli Steamed green
    4067 7 zucchini Raw green
    4090 4 spinach Raw green
    4572 7 cauliflower Steamed white
    3125 17 habanero pepper Raw orange
    4677 16 Anaheim pepper Raw green
    4088 19 red bell pepper Sauteed red
    4081 6 eggplant Fried purple
    4604 2 endive Raw green
 
    PS C:\> Get-Vegetable corn | Get-Member
 
       TypeName: PSTeachingTools.PSVegetable
 
    Name MemberType Definition
    ---- ---------- ----------
    State AliasProperty State = CookedState
    Equals Method bool Equals(System.Object obj)
    GetHashCode Method int GetHashCode()
    GetType Method type GetType()
    Peel Method void Peel()
    Prepare Method void Prepare(PSTeachingTools.VegStatus State)
    ToString Method string ToString()
    Color Property PSTeachingTools.VegColor Color {get;}
    CookedState Property PSTeachingTools.VegStatus CookedState {get;set;}
    Count Property int Count {get;set;}
    IsPeeled Property bool IsPeeled {get;set;}
    IsRoot Property bool IsRoot {get;}
    Name Property string Name {get;}
    UPC Property int UPC {get;}
 
    The default display uses the format.ps1xml file which does NOT reflect the
    complete object. This is typical PowerShell behavior. Get-Process and
    Process objects are a good example.
 
    Here are some other ways you could use the command to demonstrate common
    PowerShell techniques and concepts:
 
    PS C:\> Get-Vegetable | Group-Object -Property Color
 
    Count Name Group
    ----- ---- -----
        8 green {PSTeachingTools.PSVegetable, PSTeachingToo...
        3 red {PSTeachingTools.PSVegetable, PSTeachingToo...
        1 white {PSTeachingTools.PSVegetable}
        1 yellow {PSTeachingTools.PSVegetable}
        2 orange {PSTeachingTools.PSVegetable, PSTeachingToo...
        2 purple {PSTeachingTools.PSVegetable, PSTeachingToo...
        1 brown {PSTeachingTools.PSVegetable}
 
    PS C:\> Get-Vegetable -RootOnly | Measure-Object -Property count -sum
 
    Count : 4
    Average :
    Sum : 53
    Maximum :
    Minimum :
    StandardDeviation :
    Property : Count
 
    Read full help and examples for New-Vegetable and Set-Vegetable.
 
PSVegetable Class
    The object class and its enumerations are now exposed in PowerShell.
 
    PS C:\> [enum]::GetNames([PSTeachingTools.VegColor])
    green
    red
    white
    yellow
    orange
    purple
    brown
 
    PS C:\> [enum]::GetNames([PSTeachingTools.VegStatus])
    Raw
    Boiled
    Steamed
    Sauteed
    Fried
    Baked
    Roasted
    Grilled
 
    PS C:\> [PSTeachingTools.PSVegetable]::new.OverloadDefinitions
    PSTeachingTools.PSVegetable new(string VegetableName, bool Root, PSTeachingTools.VegColor VegetableColor, int UPCCode)
 
    The PSVegetable object has a custom format file with defined table views.
 
    PS C:\> Get-FormatView PSTeachingTools.PSVegetable
 
    Type: PSTeachingTools.PSVegetable
 
    Format Name
    ------ ----
    Table default
    Table State
    Table color
 
SEE ALSO
    https://aka.ms/powershell
    https://jdhitsolutions.com/blog/essential-powershell-resources/
    https://jdhitsolutions.com/blog/powershell-tips-tricks-and-advice/
 
KEYWORDS
    - teaching
    - demo