├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ ├── feature-request.yml │ └── other-request.yml ├── Changelog.md ├── LICENSE.txt ├── PSTeachingTools.psd1 ├── PSTeachingTools.psm1 ├── README.md ├── assets ├── get-vegetable.jpg ├── mkformat.ps1 └── set-vegetable.jpg ├── code ├── Get-Vegetable.ps1 ├── New-Vegetable.ps1 ├── Remove-Vegetable.ps1 ├── Set-Vegetable.ps1 ├── Start-TypedDemo.ps1 ├── Vegetables.ps1 ├── plu.csv ├── psteachingtools.cs ├── rawveggies.json └── vegetable-class.ps1 ├── docs ├── Get-Vegetable.md ├── New-Vegetable.md ├── Remove-Vegetable.md ├── Set-Vegetable.md ├── Start-TypedDemo.md └── about_PSTeachingTools.md ├── en-us ├── about_PSTeachingTools.help.txt └── psteachingtools-help.xml ├── formats └── vegetable.format.ps1xml ├── samples ├── sampledemo.txt └── sampledemo2.txt └── tests └── PSTeachingTools.tests.ps1 /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: https://paypal.me/jdhitsolutions?locale.x=en_US 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.yml: -------------------------------------------------------------------------------- 1 | name: 🪲 Bug Report 2 | description: Report a bug or problem. 3 | title: "[Bug]: " 4 | labels: ["bug","triage"] 5 | assignees: 6 | - jdhitsolutions 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: "## Thank you for bringing this to our attention." 11 | - type: textarea 12 | id: description 13 | attributes: 14 | label: Describe the problem 15 | description: Please describe the bug or problem including the exact syntax you are using and any error or warning messages. 16 | validations: 17 | required: true 18 | - type: textarea 19 | id: expected-behavior 20 | attributes: 21 | label: Expectation 22 | description: What did you expect to happen? 23 | - type: textarea 24 | id: additional-info 25 | attributes: 26 | label: Additional Information 27 | description: Do you have any additional information or context that you think will be helpful in resolving this issue? 28 | - type: dropdown 29 | id: psversion 30 | attributes: 31 | label: PowerShell version 32 | description: What version of PowerShell are you running? 33 | options: 34 | - '4.0' 35 | - '5.1' 36 | - 6.x 37 | - '7.0' 38 | - '7.1' 39 | - '7.2' 40 | - Other 41 | validations: 42 | required: true 43 | - type: dropdown 44 | id: platform 45 | attributes: 46 | label: Platform 47 | description: What operating system are you running? 48 | options: 49 | - Windows 10 Home 50 | - Windows 11 Home 51 | - Windows 10 Pro or Enterprise 52 | - Windows 11 Pro or Enterprise 53 | - MacOS 54 | - Linux 55 | - Other 56 | - type: checkboxes 57 | id: checks 58 | attributes: 59 | label: Additional Checks 60 | description: Have you verified the following? 61 | options: 62 | - label: You are using the latest version of this module. 63 | required: true 64 | - label: You have read this repository's README file. 65 | - label: You have read full help and examples for the command you are having problems with. 66 | - label: You are running PowerShell in an elevated session. 67 | - label: You are running in a traditional PowerShell console or Windows Terminal 68 | 69 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: README 4 | url: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/README.md 5 | about: Open this module's README.md file. 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | name: 💡Feature Request 2 | description: Request a new feature or enhancement 3 | title: "[Request]: " 4 | labels: ["enhancement","triage"] 5 | assignees: 6 | - jdhitsolutions 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: "## Thank you for bringing this to our attention." 11 | - type: textarea 12 | id: description 13 | attributes: 14 | label: Describe the request 15 | description: Please describe your feature request or enhancement in detail. What deficiency does it address in the module? What use cases support your request? 16 | validations: 17 | required: true 18 | - type: dropdown 19 | id: psversion 20 | attributes: 21 | label: PowerShell version 22 | description: What version of PowerShell are you running? 23 | options: 24 | - '4.0' 25 | - '5.1' 26 | - 6.x 27 | - '7.0' 28 | - '7.1' 29 | - '7.2' 30 | - Other 31 | validations: 32 | required: false 33 | - type: dropdown 34 | id: platform 35 | attributes: 36 | label: Platform 37 | description: What operating system are you running? 38 | options: 39 | - Windows 10 Home 40 | - Windows 11 Home 41 | - Windows 10 Pro or Enterprise 42 | - Windows 11 Pro or Enterprise 43 | - MacOS 44 | - Linux 45 | - Other 46 | 47 | 48 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other-request.yml: -------------------------------------------------------------------------------- 1 | name: 🤔Other Request or Question 2 | description: Open a request for all other issues 3 | title: "[Question]: " 4 | labels: ["question","triage"] 5 | assignees: 6 | - jdhitsolutions 7 | body: 8 | - type: textarea 9 | id: description 10 | attributes: 11 | label: Describe the question or issue 12 | description: What is on your mind? 13 | validations: 14 | required: true 15 | - type: dropdown 16 | id: psversion 17 | attributes: 18 | label: PowerShell version 19 | description: What version of PowerShell are you running? 20 | options: 21 | - '4.0' 22 | - '5.1' 23 | - 6.x 24 | - '7.0' 25 | - '7.1' 26 | - '7.2' 27 | - Other 28 | validations: 29 | required: false 30 | - type: dropdown 31 | id: platform 32 | attributes: 33 | label: Platform 34 | description: What operating system are you running? 35 | options: 36 | - Windows 10 Home 37 | - Windows 11 Home 38 | - Windows 10 Pro or Enterprise 39 | - Windows 11 Pro or Enterprise 40 | - MacOS 41 | - Linux 42 | - Other 43 | 44 | 45 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # Change Log for PSTeachingTools 2 | 3 | ## [Unreleased] 4 | 5 | ## [4.3.0] - 2024-09-03 6 | 7 | ### Added 8 | 9 | - Added a table view of vegetable objects called `Color`. This uses a new global variable called `AnsiVegColor`. 10 | - Added an alias `State` for the `CookedState` property on vegetable objects. 11 | 12 | ### Changed 13 | 14 | - Update vegetable JSON file to use proper casing for vegetable names. 15 | - General code cleanup 16 | - Modified root module to use the cooked state from the JSON data file on module import. This is technically a breaking change, but since it happens on module import, this shouldn't affect the end-user. The underlying class definition was not changed. [Issue #12](https://github.com/jdhitsolutions/PSTeachingTools/issues/12) 17 | - Updated `README.md`. 18 | - Help updates. 19 | 20 | ### Fixed 21 | 22 | - Fixed broken online help links. 23 | 24 | ## [v4.2.0] - 2022-01-11 25 | 26 | + Reorganized the module separating functions out to separate files. 27 | + Updated `Set-Vegetable` to fix bugs parsing input. [Issue #11](https://github.com/jdhitsolutions/PSTeachingTools/issues/11) 28 | 29 | ## [v4.1.0] - 2022-01-03 30 | 31 | + Updated `Start-TypedDemo` to allow the use of live commands. This is an *experimental* feature. 32 | + Updated `Start-TypedDemo` to simulate PSReadLine coloring using AST processing 33 | + Updated `Start-TypedDemo` to better simulate new lines. 34 | + Updated `Start-TypedDemo` to better distinguish `::` as a multi-line indicator instead of the static member operator. 35 | + Fixed argument completer for vegetable commands to wrap items with spaces in quotes. [Issue #10](https://github.com/jdhitsolutions/PSTeachingTools/issues/10) 36 | + Created a `samples` folder. 37 | + Finally resolved case of the `docs` folder. 38 | 39 | ## [v4.0.0] - 2021-01-05 40 | 41 | + Updated license. 42 | + Reorganized module layout. 43 | + Updated `Start-TypedDemo` to work with all versions of PowerShell 7.x. 44 | + Updated `assets\sampledemo.txt` demo script file. 45 | + Moved `vegetable` class to a C# class definition with a new namespace and name, `PSTeachingTools.PSVegetable`. Enumerations have also been re-defined as `PSTeachingTools.VegColor` and `PSTeachingTools.VegStatus`. All of these changes are to make the object class more PowerShell-like and discoverable. __BREAKING CHANGE__ 46 | + Added `Remove-Vegetable` command. 47 | + Added argument completers for the `Name` parameter in `Get-Vegetable`, `Set-Vegetable`, and `Remove-Vegetable`. 48 | + Updated help documentation. 49 | + Updated `README.md`. 50 | + Added online help links. 51 | 52 | ## [v3.2.1] - 2020-05-16 53 | 54 | + Modified module with additional verbose output to aid in troubleshooting command failures. 55 | + Moved vegetable creation from `vegetables.ps1` to the module file. 56 | + Explicitly defining `$vegetableplu` as a global variable and removing `Export-ModuleMember`. 57 | 58 | ## [v3.2.0] - 2020-04-13 59 | 60 | + Modified `Start-TypedDemo` to record commands in the `PSReadLine` History file, command history, and history buffer. 61 | + Modified `Start-TypedDemo` to create a custom transcript file. 62 | + Fixed bug in module file that was preventing aliases from being exported. 63 | + Updated `sampledemo.txt`. 64 | + Updated help for `Start-TypedDemo`. 65 | 66 | ## [v3.1.0] - 2020-04-02 67 | 68 | + Updated `Start-TypedDemo` to reflect Windows PowerShell 5.1 or PowerShell 7 sessions. 69 | + Modified `Start-TypedDemo` to use a fully-qualified command name for `Write-Host`. 70 | + Updated module to export the enumerations and class definition. 71 | + Help updates. 72 | + Added an `about` help topic file (Issue #2) 73 | + Updated `sampledemo.txt`. 74 | + Updated `License`. 75 | 76 | ## [v3.0.0] - 2019-02-21 77 | 78 | + Updated `vegetables.ps1` with cleaner code to generate a collection of vegetables from a JSON file with legitimate PLU codes. 79 | + Updated copyright year in `License.txt`. 80 | + Modified `New-Vegetable` to support `-Whatif`. 81 | + Code reformatting in `vegetables.ps1`. 82 | + Modified class constructor to use a UPC code. 83 | + Modified the layout of `vegetables.format.ps1xml`. 84 | + Added a new table view called `statedir` to `vegetables.format.ps1xml`. 85 | + renamed `Docs` to `docs`. 86 | + Updates to help documentation. 87 | 88 | ## [v2.0.0] - 2018-10-23 89 | 90 | + File cleanup for the PowerShell Gallery. 91 | + moved alias definitions to respective functions. 92 | + Updated `README.md`. 93 | + Updated license. 94 | + Removed year from the fake header in `Start-TypedDemo`. 95 | + Removed typo feature from `Start-TypedDemo`. 96 | + Added sample demo script for `Start-TypedDemo`. 97 | + Updated manifest to support Desktop and Core. 98 | + Updated help documentation. 99 | 100 | ## [v1.1.0] - 2017-06-01 101 | 102 | + minor changes to vegetable creation. 103 | + Modified `Get-Vegetable` to accept pipeline input. 104 | + Modified `Set-Vegetable` to accept pipeline input. 105 | + Updated help. 106 | 107 | ## [v1.0.1] - 2017-05-25 108 | 109 | + updated `README.md`. 110 | 111 | ## v1.0.0 - 2017-05-25 112 | 113 | + initial release to PowerShell Gallery. 114 | 115 | ## v0.0.6 - 2017-05-25 116 | 117 | + modified ps1xml code to use Join-Path 118 | + updated manifest 119 | 120 | ## v0.0.5 - 2017-05-16 121 | 122 | + updated manifest changes 123 | + updated UPC range to 4000-5000 124 | + Added `Start-TypedDemo` function and alias 125 | + updated help 126 | 127 | ## v0.0.4 - 2016-08-01 128 | 129 | + modified `New-Vegetable` parameters to accept value by property name 130 | + updated help documents 131 | + updated module zip file 132 | 133 | ## v0.0.3 - 2016-08-01 134 | 135 | + updated manifest with GitHub links 136 | + Created PowerShell module zip file 137 | 138 | ## v0.0.2 - 2016-08-01 139 | 140 | + added vegetable markdown help 141 | + created XML help for vegetable commands 142 | + added aliases for vegetable commands 143 | 144 | ## v0.0.1 - 2016-08-01 145 | 146 | + initial version with Vegetable commands 147 | + new module manifest 148 | + new README.md 149 | 150 | [Unreleased]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v4.3.0..HEAD 151 | [4.3.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/vv4.2.0..v4.3.0 152 | [v4.2.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v4.1.0..v4.2.0 153 | [v4.1.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v4.0.0..v4.1.0 154 | [v4.0.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v3.2.1..v4.0.0 155 | [v3.2.1]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v3.2.0..v3.2.1 156 | [v3.2.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v3.1.0..v3.2.0 157 | [v3.1.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v3.0.0..v3.1.0 158 | [v3.0.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v2.0.0..v3.0.0 159 | [v2.0.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v1.1.0..v2.0.0 160 | [v1.1.0]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v1.0.1..v1.1.0 161 | [v1.0.1]: https://github.com/jdhitsolutions/PSTeachingTools/compare/v1.0.0..v1.0.1 -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2024 JDH Information Technology Solutions, Inc. 4 | 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /PSTeachingTools.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSTeachingTools/fc79413e01dd8857227e60dd44756896e17eac4b/PSTeachingTools.psd1 -------------------------------------------------------------------------------- /PSTeachingTools.psm1: -------------------------------------------------------------------------------- 1 | if ($MyInvocation.Line -match '-verb') { 2 | $saved = $VerbosePreference 3 | $VerbosePreference = 'continue' 4 | } 5 | 6 | #dot source teaching commands and tools 7 | Write-Verbose 'loading vegetables.ps1' 8 | Get-ChildItem -Path $PSScriptRoot\code\*Vegetable*.ps1 | 9 | ForEach-Object { 10 | . $_.FullName 11 | } 12 | 13 | #create a global variable with PLU data 14 | Write-Verbose 'Creating $VegetablePLU' 15 | 16 | $pluPath = Join-Path "$PSScriptRoot\Code" -ChildPath plu.csv 17 | if (Test-Path -Path $pluPath ) { 18 | $global:VegetablePLU = Import-Csv -Path $pluPath 19 | } 20 | else { 21 | Write-Warning "PSTeachingTools: Failed to find $pluPath" 22 | } 23 | 24 | #region create some vegetable objects and store them in a global list 25 | Write-Verbose "Defining `$MyVegetables" 26 | $global:MyVegetables = [System.Collections.Generic.list[PSTeachingTools.PSVegetable]]::new() 27 | 28 | $rawPath = Join-Path -Path "$PSScriptRoot\Code" -ChildPath rawveggies.json 29 | if (Test-Path -Path $rawPath) { 30 | Write-Verbose "Converting vegetable data from $rawPath" 31 | $raw = Get-Content -Path $rawPath | ConvertFrom-Json 32 | #$raw | New-Vegetable 33 | #3 September 2024 - set the cooking state from the JSON file. Issue #12 34 | Foreach ($item in $raw) { 35 | $v = $item | New-Vegetable -Passthru 36 | $v.CookedState = $item.CookingState 37 | } 38 | 39 | } 40 | else { 41 | Write-Warning "Failed to find $rawPath" 42 | } 43 | 44 | #create a global hashtable of ANSI color codes used by the Color view 45 | $global:AnsiVegColor = @{ 46 | Yellow = "$([char]27)[93m" 47 | Red = "$([char]27)[91m" 48 | Green = "$([char]27)[92m" 49 | Purple = "$([char]27)[35m" 50 | Orange = "$([char]27)[38;5;220m" 51 | Brown = "$([char]27)[38;5;94m" 52 | White = "$([char]27)[97m" 53 | } 54 | 55 | #endregion 56 | 57 | Write-Verbose 'loading Start-TypedDemo.ps1' 58 | . $PSScriptRoot\Code\Start-TypedDemo.ps1 59 | 60 | #reset verbose preference 61 | $VerbosePreference = $saved -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSTeachingTools 2 | 3 | [![PSGallery Version](https://img.shields.io/powershellgallery/v/PSTeachingTools.png?style=for-the-badge&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSTeachingTools/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSTeachingTools.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/PSTeachingTools/) 4 | 5 | ## Installation 6 | 7 | Install this module from the PowerShell Gallery: 8 | 9 | ```powershell 10 | Install-Module PSTeachingTools [-scope AllUsers] 11 | ``` 12 | 13 | *Do not attempt to download and install from this repository unless you are an experienced PowerShell user.* Install the module from the PowerShell Gallery as shown above. 14 | 15 | The module should work in both Windows PowerShell and PowerShell 7, including cross-platform. Please post an issue with any feedback, suggestions, or problems. 16 | 17 | ## :teacher: Teaching PowerShell 18 | 19 | This PowerShell module includes tools and techniques for teaching PowerShell. Many of the commands will create a set of sample objects and commands that can be used to demonstrate a variety of PowerShell techniques and concepts without having to worry about anything technical like Active Directory, services, or file objects. 20 | 21 | - [Get-Vegetable](docs/Get-Vegetable.md) 22 | - [Set-Vegetable](docs/Set-Vegetable.md) 23 | - [Remove-Vegetable](docs/Remove-Vegetable.md) 24 | - [New-Vegetable](docs/New-Vegetable.md) 25 | 26 | Once the module is imported, you can use these commands like any other PowerShell command. 27 | 28 | ![Using objects in the pipeline](assets/get-vegetable.jpg) 29 | 30 | ![setting objects](assets/set-vegetable.jpg) 31 | 32 | Beginning in v4.0.0 of this module, the custom vegetable objects are exposed as publicly-defined objects with a variety of properties and methods. Some of the properties are read-only. Associated enumerations are also now publicly available. 33 | 34 | ```powershell 35 | PS C:\> Get-Vegetable Corn | Get-Member 36 | 37 | TypeName: PSTeachingTools.PSVegetable 38 | 39 | Name MemberType Definition 40 | ---- ---------- ---------- 41 | State AliasProperty State = CookedState 42 | Equals Method bool Equals(System.Object obj) 43 | GetHashCode Method int GetHashCode() 44 | GetType Method type GetType() 45 | Peel Method void Peel() 46 | Prepare Method void Prepare(PSTeachingTools.VegStatus State) 47 | ToString Method string ToString() 48 | Color Property PSTeachingTools.VegColor Color {get;} 49 | CookedState Property PSTeachingTools.VegStatus CookedState {get;set;} 50 | Count Property int Count {get;set;} 51 | IsPeeled Property bool IsPeeled {get;set;} 52 | IsRoot Property bool IsRoot {get;} 53 | Name Property string Name {get;} 54 | UPC Property int UPC {get;} 55 | 56 | PS C:\> [PSTeachingTools.VegStatus]::Sauteed 57 | Sauteed 58 | ``` 59 | 60 | The `PSVegetable` object has a custom format file with defined table views. 61 | 62 | ```powershell 63 | PS C:\> Get-FormatView PSTeachingTools.PSVegetable 64 | 65 | Type: PSTeachingTools.PSVegetable 66 | 67 | Format Name 68 | ------ ---- 69 | Table default 70 | Table State 71 | Table color 72 | ``` 73 | 74 | This means you can run a command like: 75 | 76 | ```powershell 77 | PS C:\> Get-Vegetable | Format-Table -View color 78 | ``` 79 | 80 | The `Color` view relies on ANSI values stored in the `$AnsiVegColor` hashtable. 81 | 82 | The primary idea behind these commands is that you can use them to teach core PowerShell concepts and techniques. Once the student understands how vegetable objects work in the pipeline, it is a small step to files, processes, and services. 83 | 84 | See the [about_PSTeachingTools](docs/about_PSTeachingTools.md) help file for more information. 85 | 86 | ## :robot: Typed Demos 87 | 88 | The module also includes a function for simulating an interactive PowerShell console session. You can type your commands in a file and have the function "play back" the commands just as if you were typing the commands. The function will pause after every `|` character. Pressing `Enter` will advance the demo. The commands from the demo file will also be added to the session's command history. 89 | 90 | ### Live Commands 91 | 92 | Starting in v4.1.0, you can insert `` into your demo file. When `Start-TypedDemo` reaches this line, it will let you enter a live command. Enter a command carefully and without error. Backspaces will break this step. Due to timing, the first key stroke may not be detected. This feature should be considered *experimental*. 93 | 94 | Read command help for [Start-TypedDemo](docs/Start-TypedDemo.md). A [sample file](samples/sampledemo.txt) is included in this module. 95 | 96 | Learn more about PowerShell: [http://jdhitsolutions.com/blog/essential-powershell-resources/](http://jdhitsolutions.com/blog/essential-powershell-resources/) 97 | 98 | ## Sponsorship 99 | 100 | If you find this module helpful or valuable, especially if used in a commercial setting, a small token of sponsorship would be deeply appreciated. 101 | -------------------------------------------------------------------------------- /assets/get-vegetable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSTeachingTools/fc79413e01dd8857227e60dd44756896e17eac4b/assets/get-vegetable.jpg -------------------------------------------------------------------------------- /assets/mkformat.ps1: -------------------------------------------------------------------------------- 1 | 2 | <# 3 | code used to generate the XML format file 4 | This script file is not a published part of the module 5 | #> 6 | 7 | #formatting directives for the custom object 8 | [xml]$format = @" 9 | 10 | 11 | 12 | 13 | default 14 | 15 | PSTeachingTools.PSVegetable 16 | 17 | 18 | 19 | 20 | 21 | 22 | 5 23 | left 24 | 25 | 26 | 27 | 7 28 | right 29 | 30 | 31 | 32 | 13 33 | left 34 | 35 | 36 | 37 | 8 38 | left 39 | 40 | 41 | 42 | 10 43 | left 44 | 45 | 46 | 47 | 48 | 49 | 50 | UPC 51 | 52 | 53 | Count 54 | 55 | 56 | Name 57 | 58 | 59 | CookedState 60 | 61 | 62 | Color 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | "@ 72 | 73 | #use Join-Path to avoid problems with open source platforms 74 | $outfile = Join-Path -path $PSScriptRoot -childpath vegetable.format.ps1xml 75 | if (-Not (Test-Path -path $outFile)) { 76 | $format.Save($outFile) 77 | } 78 | 79 | Update-FormatData -AppendPath $outfile 80 | -------------------------------------------------------------------------------- /assets/set-vegetable.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSTeachingTools/fc79413e01dd8857227e60dd44756896e17eac4b/assets/set-vegetable.jpg -------------------------------------------------------------------------------- /code/Get-Vegetable.ps1: -------------------------------------------------------------------------------- 1 | Function Get-Vegetable { 2 | [CmdletBinding()] 3 | [OutputType("PSTeachingTools.PSVegetable")] 4 | [alias("gveg")] 5 | 6 | Param( 7 | [Parameter( 8 | Position = 0, 9 | ValueFromPipeline, 10 | ValueFromPipelineByPropertyName 11 | )] 12 | [String]$Name, 13 | 14 | [Switch]$RootOnly 15 | ) 16 | 17 | Begin { 18 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 19 | } 20 | 21 | Process { 22 | #verify the MyVegetables array exists 23 | if ( $global:MyVegetables.count -gt 0) { 24 | Write-Verbose "[PROCESS] Processing $($global:MyVegetables.count) items." 25 | if ($name -AND $RootOnly) { 26 | Write-Verbose "[PROCESS] Getting vegetable $name where it is a root vegetable" 27 | ($global:MyVegetables).where( { ($_.IsRoot) -And ($_.name -like $name) }) 28 | # $global:MyVegetables | where {($_.IsRoot) -And ($_.name -like $name)} 29 | } 30 | elseif ($Name) { 31 | Write-Verbose "[PROCESS] Getting vegetable $name" 32 | $result = ($global:MyVegetables).where( { $_.name -like $name }) 33 | if ($result) { 34 | $result 35 | } 36 | else { 37 | Throw "Can't find a vegetable with the name $Name" 38 | } 39 | } 40 | elseif ($RootOnly) { 41 | Write-Verbose "[PROCESS] Getting root vegetables only" 42 | ($global:MyVegetables).where( { $_.IsRoot }) 43 | } 44 | else { 45 | Write-Verbose "[PROCESS] Getting all vegetables" 46 | $global:MyVegetables 47 | } 48 | } #if MyVegetables 49 | else { 50 | Write-Warning "Failed to find vegetable source." 51 | } 52 | } #Process 53 | 54 | End { 55 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /code/New-Vegetable.ps1: -------------------------------------------------------------------------------- 1 | Function New-Vegetable { 2 | [CmdletBinding(SupportsShouldProcess)] 3 | [OutputType("none", "PSTeachingTools.PSVegetable")] 4 | [alias("nveg")] 5 | 6 | Param( 7 | [Parameter( 8 | Position = 0, 9 | Mandatory, 10 | HelpMessage = "What is the vegetable name?", 11 | ValueFromPipelineByPropertyName 12 | )] 13 | [ValidateNotNullOrEmpty()] 14 | [String]$Name, 15 | 16 | [Parameter( 17 | Position = 1, 18 | Mandatory, 19 | HelpMessage = "What is the vegetable color?", 20 | ValueFromPipelineByPropertyName 21 | )] 22 | [ValidateNotNullOrEmpty()] 23 | [PSTeachingTools.VegColor]$Color, 24 | 25 | [Parameter(ValueFromPipelineByPropertyName)] 26 | [ValidateRange(1, 20)] 27 | [Int]$Count = 1, 28 | 29 | [Parameter(ValueFromPipelineByPropertyName)] 30 | [alias("IsRoot")] 31 | [Switch]$Root, 32 | 33 | [Parameter( 34 | Mandatory, 35 | HelpMessage = "Enter a valid PLU code", 36 | ValueFromPipelineByPropertyName 37 | )] 38 | [Int]$UPC, 39 | 40 | [Switch]$PassThru 41 | ) 42 | 43 | Begin { 44 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 45 | } 46 | 47 | Process { 48 | if ($PSCmdlet.ShouldProcess($Name)) { 49 | Write-Verbose "[PROCESS] Creating [$UPC] $name Color: $color RootVegetable: $Root" 50 | $veggie = [PSTeachingTools.PSVegetable]::new($name, $Root, $color, $UPC) 51 | 52 | if ($veggie) { 53 | $veggie.count = $Count 54 | Write-Verbose "Adding to global list" 55 | $global:MyVegetables.Add($veggie) 56 | 57 | if ($PassThru) { 58 | Write-Output $veggie 59 | } 60 | } 61 | else { 62 | Write-Warning "Oops. Something unexpected happened." 63 | } 64 | } #should process 65 | } #process 66 | 67 | End { 68 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 69 | } #end 70 | } 71 | -------------------------------------------------------------------------------- /code/Remove-Vegetable.ps1: -------------------------------------------------------------------------------- 1 | Function Remove-Vegetable { 2 | [CmdletBinding(SupportsShouldProcess)] 3 | [OutputType("none", "PSTeachingTools.PSVegetable")] 4 | [Alias("rveg")] 5 | Param( 6 | [Parameter( 7 | Position = 0, 8 | ValueFromPipeline, 9 | ParameterSetName = "input" 10 | )] 11 | [PSTeachingTools.PSVegetable[]]$InputObject, 12 | 13 | [Parameter( 14 | Position = 0, 15 | ValueFromPipeline, 16 | ValueFromPipelineByPropertyName, 17 | ParameterSetName = "name" 18 | )] 19 | [String]$Name, 20 | 21 | [Parameter(HelpMessage = "Write the removed object to the pipeline")] 22 | [Switch]$PassThru 23 | ) 24 | Begin { 25 | Write-Verbose "[$((Get-Date).TimeOfDay) BEGIN ] Starting $($MyInvocation.MyCommand)" 26 | } #begin 27 | 28 | Process { 29 | if ($PSCmdlet.ParameterSetName -eq 'name') { 30 | $InputObject = $global:MyVegetables.Where( { $_.Name -like $Name }) 31 | if (-Not $InputObject) { 32 | Write-Warning "Failed to find a vegetable called $name" 33 | } 34 | } 35 | If ($InputObject) { 36 | foreach ($item in $InputObject) { 37 | Write-Verbose "[$((Get-Date).TimeOfDay) PROCESS] Removing $($item.name)" 38 | if ($PSCmdlet.ShouldProcess($item.name)) { 39 | [void]($global:MyVegetables.remove($item)) 40 | if ($PassThru) { 41 | $item 42 | } 43 | } #WhatIf 44 | } #foreach item 45 | } #if InputObject 46 | } #process 47 | 48 | End { 49 | Write-Verbose "[$((Get-Date).TimeOfDay) END ] Ending $($MyInvocation.MyCommand)" 50 | } #end 51 | 52 | } 53 | -------------------------------------------------------------------------------- /code/Set-Vegetable.ps1: -------------------------------------------------------------------------------- 1 | Function Set-Vegetable { 2 | [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = "input")] 3 | [OutputType("None", "PSTeachingTools.PSVegetable")] 4 | [Alias("sveg")] 5 | 6 | Param( 7 | [Parameter( 8 | Position = 0, 9 | ValueFromPipeline, 10 | ParameterSetName = "input" 11 | )] 12 | [PSTeachingTools.PSVegetable[]]$InputObject, 13 | 14 | [Parameter( 15 | Position = 0, 16 | ValueFromPipeline, 17 | ParameterSetName = "name" 18 | )] 19 | [String]$Name, 20 | 21 | [Parameter()] 22 | [Int]$Count, 23 | 24 | [Parameter()] 25 | [alias("state")] 26 | [PSTeachingTools.VegStatus]$CookingState, 27 | 28 | [Switch]$PassThru 29 | ) 30 | 31 | Begin { 32 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 33 | } #begin 34 | 35 | Process { 36 | Write-Verbose "[PROCESS] Detected parameter set $($PSCmdlet.ParameterSetName)" 37 | $PSBoundParameters | Out-String | Write-Verbose 38 | if ($PSCmdlet.ParameterSetName -eq 'name') { 39 | $InputObject = $global:MyVegetables.Where( { $_.Name -like $Name }) 40 | if (-Not $InputObject) { 41 | Write-Warning "Failed to find a vegetable called $name" 42 | } 43 | } 44 | If ($InputObject) { 45 | foreach ($item in $InputObject) { 46 | Write-Verbose "[PROCESS] Modifying $($item.name)" 47 | if ($PSCmdlet.ShouldProcess($item.name)) { 48 | if ($PSBoundParameters.ContainsKey("CookingState")) { 49 | Write-Verbose "[PROCESS] Updating cooking state to $cookingstate" 50 | $item.Prepare($CookingState) 51 | } 52 | if ($PSBoundParameters.ContainsKey("Count")) { 53 | Write-Verbose "[PROCESS] Updating count to $count" 54 | $item.count = $count 55 | } 56 | if ($PassThru) { 57 | $item 58 | } 59 | } 60 | } #foreach 61 | } #if input 62 | } 63 | 64 | End { 65 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 66 | } #end 67 | } 68 | -------------------------------------------------------------------------------- /code/Start-TypedDemo.ps1: -------------------------------------------------------------------------------- 1 | #requires -modules @{ModuleName='PSReadLine';ModuleVersion='2.0.0'} 2 | 3 | Function Start-TypedDemo { 4 | [CmdletBinding(DefaultParameterSetName = "Random")] 5 | [Alias("std")] 6 | 7 | Param( 8 | [Parameter(Position = 0, Mandatory = $True, HelpMessage = "Enter the name of a text file with your demo commands")] 9 | [ValidateScript( { Test-Path $_ })] 10 | [String]$File, 11 | [ValidateScript( {$_ -gt 0 })] 12 | [Parameter(Mandatory,ParameterSetName = "Static")] 13 | [Int]$Pause, 14 | [Parameter(ParameterSetName = "Random")] 15 | [ValidateScript( { $_ -gt 0 })] 16 | [Int]$RandomMinimum = 50, 17 | [Parameter(ParameterSetName = "Random")] 18 | [ValidateScript( { $_ -gt 0 })] 19 | [Int]$RandomMaximum = 110, 20 | [Parameter(ParameterSetName = "Random")] 21 | [parameter(HelpMessage = "Enter the path for a transcript file")] 22 | [ValidateNotNullOrEmpty()] 23 | [String]$Transcript, 24 | [Switch]$NoExecute, 25 | [Switch]$NewSession 26 | ) 27 | 28 | #this is an internal function so I'm not worried about the name 29 | Function PauseIt { 30 | [CmdletBinding()] 31 | Param() 32 | Write-Verbose "PauseIt" 33 | 34 | #wait for a key press 35 | $Running = $true 36 | #keep looping until a key is pressed 37 | While ($Running) { 38 | if ($host.UI.RawUI.KeyAvailable) { 39 | $key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") 40 | if ($key) { 41 | $Running = $False 42 | #check the value and if it is q or ESC, then bail out 43 | if ($key -match "q|27") { 44 | Microsoft.PowerShell.Utility\Write-Host "`r" 45 | Return "quit" 46 | } #if match q|27 47 | } #if $key 48 | } #if key available 49 | Start-Sleep -millisecond 100 50 | } #end While 51 | } #PauseIt function 52 | 53 | Function EnterCommand { 54 | [CmdletBinding()] 55 | Param() 56 | $typing = $true 57 | #keep looping until a key is pressed 58 | $list = [System.Collections.Generic.list[object]]::new() 59 | do { 60 | if ($host.UI.RawUI.KeyAvailable) { 61 | $key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") 62 | if ($key.VirtualKeyCode -eq 13) { 63 | $typing = $False 64 | } #if return 65 | else { 66 | Microsoft.PowerShell.Utility\Write-Host $key.Character -NoNewline 67 | $list.add($key.character) 68 | } 69 | } #if key available 70 | # Start-Sleep -millisecond 10 71 | } while ($typing) #end do 72 | 73 | $cmd = $list -join "" 74 | $sb = [scriptblock]::create($cmd) 75 | $start = Get-Date 76 | Invoke-Command -ScriptBlock $sb -OutVariable result | Out-Host 77 | $end = Get-Date 78 | if ($RunningTranscript) { 79 | "$(prompt)$Cmd" | Out-File -FilePath $Transcript -Encoding ascii -ErrorAction Stop -Append 80 | $result | Out-File -FilePath $Transcript -Encoding ascii -ErrorAction Stop -Append 81 | } 82 | #add to PSReadLineHistory 83 | [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($cmd) 84 | 85 | $h = @{ 86 | PSTypeName = "Microsoft.PowerShell.Commands.HistoryInfo" 87 | CommandLine = $cmd 88 | StartExecutionTime = $start 89 | } 90 | 91 | [DateTime]$end = [DateTime]::now 92 | $h.Add("EndExecutionTime", $end) 93 | $h.Add("ExecutionStatus", "Completed") 94 | if ($PSVersionTable.PSVersion.major -eq 7) { 95 | $h.add("Duration", (New-TimeSpan -Start $start -End $End)) 96 | } 97 | [PSCustomObject]$h | Add-History 98 | 99 | } #enterCommand function 100 | 101 | Function WriteWord { 102 | [CmdletBinding()] 103 | Param([String]$command) 104 | 105 | Write-Debug $command 106 | Function writechar { 107 | [CmdletBinding()] 108 | Param([String]$word, [String]$color) 109 | 110 | for ($i = 0; $i -lt $word.length; $i++) { 111 | 112 | #write the character 113 | Write-Verbose "Writing character $($word[$i])" 114 | Microsoft.PowerShell.Utility\Write-Host $word[$i] -NoNewline -ForegroundColor $color 115 | 116 | #insert a pause to simulate typing 117 | if ($Pause) { 118 | $rest = $pause 119 | } 120 | else { 121 | $rest = Get-Random -Minimum $RandomMinimum -Maximum $RandomMaximum 122 | } 123 | Start-Sleep -Milliseconds $rest 124 | 125 | if ($word -eq "|") { 126 | If ((PauseIt) -eq "quit") { Return } 127 | } 128 | 129 | } #for 130 | #Write-Host " " -NoNewline 131 | } #writechar 132 | 133 | $sb = [scriptblock]::Create($command) 134 | New-Variable astTokens -Force 135 | New-Variable astErr -Force 136 | 137 | $ast = [System.Management.Automation.Language.Parser]::ParseInput($sb, [ref]$astTokens, [ref]$astErr) 138 | 139 | $run = $False 140 | foreach ($item in $asttokens) { 141 | #insert spaces 142 | if ($Run -AND ($item.Extent.StartOffset -gt $last)) { 143 | Microsoft.PowerShell.Utility\Write-Host " " -NoNewline 144 | } 145 | if ($item.kind -eq 'NewLine') { 146 | If ((PauseIt) -eq "quit") { Return } 147 | Microsoft.PowerShell.Utility\Write-Host "" 148 | Microsoft.PowerShell.Utility\Write-Host ">>" -NoNewline 149 | $Inmulti = $True 150 | } 151 | else { 152 | if ($item.TokenFlags -match "Operator") { 153 | $color = "darkgray" 154 | } 155 | Else { 156 | switch -regex ($item.Kind) { 157 | "Generic" { $color = "Yellow" } 158 | "Variable" { $color = "green" } 159 | "String" { $color = "darkcyan" } 160 | "Parameter" { $color = "darkgray" } 161 | default { $color = "white" } 162 | } 163 | } 164 | writechar -word $item.text -color $color 165 | $run = $True 166 | $last = $item.Extent.EndOffset 167 | } #not a new line 168 | } 169 | 170 | If ($Inmulti) { 171 | Microsoft.PowerShell.Utility\Write-Host "" 172 | } 173 | 174 | } #WriteWord function 175 | 176 | #abort if NOT running in the console host 177 | if ($host.name -ne "ConsoleHost") { 178 | Write-Warning "This command will only work in Windows PowerShell or PowerShell 7.x console host." 179 | Return 180 | } 181 | 182 | Clear-Host 183 | 184 | if ($NewSession) { 185 | #simulate a new PowerShell session 186 | #define a set of coordinates 187 | $z = New-Object System.Management.Automation.Host.Coordinates 0, 0 188 | 189 | #get a header based on what version you are using. 190 | Switch -Regex ($PSVersionTable.PSVersion.ToString()) { 191 | "^5.1" { 192 | $header = @" 193 | Windows PowerShell 194 | Copyright (C) Microsoft Corporation. All rights reserved. 195 | 196 | Try the new cross-platform PowerShell https://aka.ms/pscore6 197 | 198 | "@ 199 | } #5.1 200 | "^7\." { 201 | $header = @" 202 | PowerShell $($PSVersionTable.PSVersion.ToString()) 203 | Copyright (c) Microsoft Corporation. All rights reserved. 204 | 205 | https://aka.ms/PowerShell 206 | Type 'help' to get help. 207 | 208 | "@ 209 | } #7.0 210 | Default { 211 | Write-Warning "This function only supports Windows PowerShell 5.1 or PowerShell 7." 212 | #abort the command 213 | return 214 | } 215 | } #switch 216 | 217 | Microsoft.PowerShell.Utility\Write-Host $header 218 | } #if new session 219 | 220 | if ($Transcript) { 221 | Try { 222 | $RunningTranscript = $True 223 | $startTranscript = @" 224 | 225 | ******************************* 226 | PowerShell transcript start 227 | Start time: $(Get-Date) 228 | ******************************* 229 | 230 | "@ 231 | $startTranscript | Out-File -FilePath $Transcript -Encoding ascii -ErrorAction Stop 232 | } 233 | Catch { 234 | Write-Warning "Could not start a transcript. One may already be running." 235 | } 236 | } 237 | else { 238 | $RunningTranscript = $False 239 | } 240 | #strip out all comments and blank lines 241 | Write-Verbose "Getting commands from $file" 242 | 243 | $commands = Get-Content -Path $file | Where-Object { $_ -notmatch "^#|(Return)" -AND $_ -match "\w|::|{|}|\(|\)" } 244 | 245 | $count = 0 246 | 247 | #write a prompt using your current prompt function 248 | Write-Verbose "prompt" 249 | Microsoft.PowerShell.Utility\Write-Host $(prompt) -NoNewline 250 | 251 | $NoMultiLine = $True 252 | $StartMulti = $False 253 | 254 | #define a scriptblock to get typing interval 255 | Write-Verbose "Defining interval scriptblock" 256 | $interval = { 257 | if ($PSCmdlet.ParameterSetName -eq "Random") { 258 | #get a random pause interval 259 | Get-Random -Minimum $RandomMinimum -Maximum $RandomMaximum 260 | } 261 | else { 262 | #use the static pause value 263 | $Pause 264 | } 265 | } #end Interval scriptblock 266 | 267 | Write-Verbose "Defining PipeCheck Scriptblock" 268 | #define a scriptblock to pause at a | character in case an explanation is needed 269 | $PipeCheck = { 270 | if ($command[$i] -eq "|") { 271 | If ((PauseIt) -eq "quit") { Return } 272 | } 273 | } #end PipeCheck scriptblock 274 | 275 | Write-Verbose "Processing commands" 276 | foreach ($command in $commands) { 277 | #trim off any spaces 278 | $command = $command.Trim() 279 | Write-Debug "processing: $command" 280 | $count++ 281 | #pause until a key is pressed which will then process the next command 282 | if ($NoMultiLine) { 283 | If ((PauseIt) -eq "quit") { Return } 284 | } 285 | if ($command -eq "") { 286 | Write-Debug "going live" 287 | if ($NoExecute) { 288 | "# Insert live PowerShell here" 289 | } 290 | else { 291 | entercommand 292 | } 293 | } 294 | #SINGLE LINE COMMAND 295 | elseif ($command -notmatch "^::" -AND $NoMultiLine) { 296 | Write-Debug "single line command: $command" 297 | 298 | WriteWord $command 299 | 300 | #remove the backtick line continuation character if found 301 | if ($command.contains('`')) { 302 | $command = $command.Replace('`', "") 303 | } 304 | 305 | #Pause until ready to run the command 306 | If ((PauseIt) -eq "quit") { Return } 307 | Microsoft.PowerShell.Utility\Write-Host "`r" # "`n" 308 | #execute the command unless -NoExecute was specified 309 | if ($RunningTranscript) { 310 | "$(prompt)$Command" | Out-File -FilePath $Transcript -Encoding ascii -ErrorAction Stop -Append 311 | } 312 | if (-NOT $NoExecute) { 313 | [DateTime]$start = [DateTime]::now 314 | $h = @{ 315 | PSTypeName = "Microsoft.PowerShell.Commands.HistoryInfo" 316 | CommandLine = $Command 317 | StartExecutionTime = $start 318 | } 319 | 320 | Invoke-Expression $command -OutVariable rex | Out-Default 321 | # Invoke-Command -ScriptBlock ([scriptblock]::Create($command)) -NoNewScope -OutVariable rex | Out-Default 322 | if ($RunningTranscript) { 323 | $rex | Out-File -FilePath $Transcript -Encoding ascii -Append -ErrorAction stop 324 | } 325 | 326 | #Add to PSReadLine History 327 | [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($command) 328 | 329 | #Add to command history 330 | [DateTime]$end = [DateTime]::now 331 | $h.Add("EndExecutionTime", $end) 332 | $h.Add("ExecutionStatus", "Completed") 333 | if ($PSVersionTable.PSVersion.major -eq 7) { 334 | $h.add("Duration", (New-TimeSpan -Start $start -End $End)) 335 | } 336 | [PSCustomObject]$h | Add-History 337 | } 338 | else { 339 | Microsoft.PowerShell.Utility\Write-Host $command -ForegroundColor Cyan 340 | } 341 | } #IF SINGLE COMMAND 342 | #START MULTILINE 343 | #skip the :: 344 | elseif ($command -match "^::" -AND $NoMultiLine) { 345 | $NoMultiLine = $False 346 | $StartMulti = $True 347 | Write-Debug "initializing `$multi" 348 | #define a variable to hold the multiline expression 349 | [String]$multi = @' 350 | 351 | '@ 352 | } #elseif 353 | #FIRST LINE OF MULTILINE 354 | elseif ($StartMulti) { 355 | 356 | <# 357 | $command.split() | ForEach-Object { WriteWord $_ } 358 | Start-Sleep -Milliseconds $(&$Interval) 359 | #only check for a pipe if we're not at the last character 360 | #because we're going to pause anyway 361 | if ($i -lt $command.length - 1) { 362 | &$PipeCheck 363 | } 364 | #> 365 | <# 366 | for ($i = 0; $i -lt $command.length; $i++) { 367 | 368 | else { 369 | # Microsoft.PowerShell.Utility\Write-Host $command[$i] -NoNewline 370 | Write-Host "" 371 | } #else 372 | Start-Sleep -Milliseconds $(&$Interval) 373 | #only check for a pipe if we're not at the last character 374 | #because we're going to pause anyway 375 | if ($i -lt $command.length - 1) { 376 | &$PipeCheck 377 | } 378 | } #for #> 379 | 380 | $StartMulti = $False 381 | 382 | #remove the backtick line continuation character if found 383 | # if ($command.contains('`')) { 384 | # $command = $command.Replace('`', "") 385 | # } 386 | #add the command to the multiline variable 387 | Write-Debug "Adding $command to `$multi" 388 | $multi += "$command`r" 389 | # if (!$command.Endswith('{')) { $multi += ";" } 390 | # if ($command -notmatch ",$|{$|}$|\|$|\($") { $multi += " ; " } 391 | If ((PauseIt) -eq "quit") { Return } 392 | 393 | } #elseif 394 | elseif (!$NoMultiline) { 395 | #add next line 396 | if ($command -match "^::") { 397 | Write-Debug "ending multiline" 398 | WriteWord $multi 399 | $NoMultiLine = $True 400 | 401 | $cmd = $multi # $(($multi -replace ';(\s=?)$', '').trim()) 402 | Write-Debug "cmd = $cmd" 403 | #Microsoft.PowerShell.Utility\Write-Host "`r" 404 | 405 | if ($RunningTranscript) { 406 | "$(prompt)$cmd" | Out-File -path $Transcript -Encoding ascii -ErrorAction Stop -Append 407 | } 408 | if (-NOT $NoExecute) { 409 | [DateTime]$start = [DateTime]::now 410 | $h = @{ 411 | CommandLine = $cmd 412 | StartExecutionTime = $start 413 | } 414 | Invoke-Expression $cmd -OutVariable rex | Out-Default 415 | #Invoke-Command -ScriptBlock ([scriptblock]::Create($cmd)) -NoNewScope -OutVariable rex | Out-Default 416 | 417 | if ($RunningTranscript) { 418 | $rex | Out-File -FilePath $Transcript -Encoding ascii -Append -ErrorAction stop 419 | } 420 | #Add clean command to PSReadLine History 421 | [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($cmd) 422 | 423 | #Add to command history 424 | [DateTime]$end = [DateTime]::now 425 | $h.Add("EndExecutionTime", $end) 426 | $h.Add("ExecutionStatus", "Completed") 427 | if ($PSVersionTable.PSVersion.major -eq 7) { 428 | $h.add("Duration", (New-TimeSpan -Start $start -End $end)) 429 | } 430 | [PSCustomObject]$h | Add-History 431 | } 432 | else { 433 | Microsoft.PowerShell.Utility\Write-Host $cmd -ForegroundColor Cyan 434 | } 435 | } 436 | else { 437 | Write-Debug "Adding $command to `$multi" 438 | $multi += "$command`r" 439 | } 440 | } 441 | #END OF MULTILINE 442 | elseif ($command -match "^::" -AND !$NoMultiLine) { 443 | #TODO This might be deleted 444 | # Microsoft.PowerShell.Utility\Write-Host "`r" 445 | # Microsoft.PowerShell.Utility\Write-Host ">> " -NoNewline 446 | Write-Debug "show multiline" 447 | WriteWord $multi 448 | 449 | $NoMultiLine = $True 450 | 451 | Write-Warning "execute multi" 452 | #If ((PauseIt) -eq "quit") { Return } 453 | #execute the command unless -NoExecute was specified 454 | Microsoft.PowerShell.Utility\Write-Host "`r" 455 | $cmd = $multi # $(($multi -replace ';(\s=?)$', '').trim()) 456 | Write-Warning "cmd = $cmd" 457 | if ($RunningTranscript) { 458 | "$(prompt)$cmd" | Out-File -path $Transcript -Encoding ascii -ErrorAction Stop -Append 459 | } 460 | if (-NOT $NoExecute) { 461 | [DateTime]$start = [DateTime]::now 462 | $h = @{ 463 | CommandLine = $cmd 464 | StartExecutionTime = $start 465 | } 466 | Invoke-Expression $cmd -OutVariable rex | Out-Default 467 | #Invoke-Command -ScriptBlock ([scriptblock]::Create($cmd)) -NoNewScope -OutVariable rex | Out-Default 468 | 469 | if ($RunningTranscript) { 470 | $rex | Out-File -FilePath $Transcript -Encoding ascii -Append -ErrorAction stop 471 | } 472 | #Add clean command to PSReadLine History 473 | [Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($cmd) 474 | 475 | #Add to command history 476 | [DateTime]$end = [DateTime]::now 477 | $h.Add("EndExecutionTime", $end) 478 | $h.Add("ExecutionStatus", "Completed") 479 | if ($PSVersionTable.PSVersion.major -eq 7) { 480 | $h.add("Duration", (New-TimeSpan -Start $start -End $end)) 481 | } 482 | [PSCustomObject]$h | Add-History 483 | } 484 | else { 485 | Microsoft.PowerShell.Utility\Write-Host $cmd -ForegroundColor Cyan 486 | } 487 | } #elseif end of multiline 488 | #NESTED PROMPTS 489 | else { 490 | #TODO I think this can be deleted 491 | Write-Debug "in nested prompts" 492 | Microsoft.PowerShell.Utility\Write-Host "`r" 493 | Microsoft.PowerShell.Utility\Write-Host ">> " -NoNewline 494 | If ((PauseIt) -eq "quit") { Return } 495 | $command.split() | ForEach-Object { WriteWord $_ } 496 | Start-Sleep -Milliseconds $(&$Interval) 497 | &$PipeCheck 498 | <# 499 | for ($i = 0; $i -lt $command.length; $i++) { 500 | else { 501 | # Microsoft.PowerShell.Utility\Write-Host $command[$i] -NoNewline 502 | } 503 | Start-Sleep -Milliseconds $(&$Interval) 504 | &$PipeCheck 505 | } #for #> 506 | 507 | #remove the backtick line continuation character if found 508 | if ($command.contains('`')) { 509 | $command = $command.Replace('`', "") 510 | } 511 | #add the command to the multiline variable and include the line break 512 | #character 513 | $multi += " $command" 514 | # if (!$command.Endswith('{')) { $multi += ";" } 515 | 516 | if ($command -notmatch ",$|{$|\|$|\($") { 517 | $multi += " ; " 518 | #$command 519 | } 520 | 521 | } #else nested prompts 522 | 523 | #reset the prompt unless we've just done the last command 524 | if (($count -lt $commands.count) -AND ($NoMultiLine)) { 525 | Write-Debug "prompt" 526 | Microsoft.PowerShell.Utility\Write-Host $(prompt) -NoNewline 527 | } 528 | 529 | } #foreach command 530 | 531 | #stop a transcript if it is running 532 | if ($RunningTranscript) { 533 | #stop this transcript if it is running 534 | # Stop-Transcript | Out-Null 535 | $stopTranscript = @" 536 | 537 | ******************************* 538 | PowerShell transcript end 539 | End time: $(Get-Date) 540 | ******************************* 541 | 542 | "@ 543 | $stopTranscript | Out-File -path $Transcript -Encoding ascii -ErrorAction Stop -Append 544 | } 545 | Write-Debug "end" 546 | } #function 547 | 548 | 549 | 550 | -------------------------------------------------------------------------------- /code/Vegetables.ps1: -------------------------------------------------------------------------------- 1 | #create an argument completer for a subset of vegetable commands 2 | $verbs = "Get","Set","Remove" 3 | foreach ($verb in $verbs) { 4 | Register-ArgumentCompleter -CommandName "$verb-Vegetable" -ParameterName Name -ScriptBlock { 5 | param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) 6 | 7 | #PowerShell code to populate $wordToComplete 8 | $global:MyVegetables.name | Where-Object { $_ -Like "$WordToComplete*" } | 9 | ForEach-Object { 10 | #wrap items with spaces in quotes [Issue #10] 11 | if ($_ -match "\s") { 12 | $complete = "'$_'" 13 | } 14 | else { 15 | $complete = $_ 16 | } 17 | # completion text,listItem text,result type,Tooltip 18 | [System.Management.Automation.CompletionResult]::new($complete, $complete, 'ParameterValue', $complete) 19 | } 20 | } 21 | } 22 | 23 | #Add object property aliases 24 | 25 | Update-TypeData -TypeName PSTeachingTools.PSVegetable -MemberType AliasProperty -MemberName "State" -Value "CookedState" -Force 26 | -------------------------------------------------------------------------------- /code/plu.csv: -------------------------------------------------------------------------------- 1 | PLUCode,Name 2 | 3000,Alkmene Apples 3 | 3001,Small Aurora/Southern Rose Apples 4 | 3002,Cantared Apples 5 | 3003,D'Estivale Apples 6 | 3004,Discovery Apples 7 | 3005,Golden Delicious Blush Apples 8 | 3006,Ingrid Marie Apples 9 | 3007,Lochbuie Apples 10 | 3008,Rubinette Apples 11 | 3009,Russet Apples 12 | 3010,Small Cripps Red Apples 13 | 3011,Worcester Apples 14 | 3012,Abate Fetel Pears 15 | 3013,Beurre Hardy Pears 16 | 3014,Bon Rouge Pears 17 | 3015,Clara Friis Pears 18 | 3016,Concorde Pears 19 | 3017,Conference Pears 20 | 3018,Durondeau Pears 21 | 3019,Flamingo Pears 22 | 3020,General Leclerc Pears 23 | 3021,Guyot Pears 24 | 3022,Josephine Pears 25 | 3023,Small Passe Crassane Pears 26 | 3024,Rocha Pears 27 | 3025,Rosemarie Pears 28 | 3026,Triumph de Vienne Pears 29 | 3027,Shamouti Oranges 30 | 3028,Small Delta Seedless Oranges 31 | 3029,Satsuma Tangerines/mandarins 32 | 3030,Nova Tangerines/mandarins 33 | 3031,Jamaican Tangor Tangerines/mandarins 34 | 3032,Ellendale Tangerines/mandarins 35 | 3033,Small Charentais Melon 36 | 3034,Large Charentais Melon 37 | 3035,"Large White Flesh, Tree Ripened, Ready-to-eat Nectarine" 38 | 3036,Small Midknight Oranges 39 | 3037,Queen Pineapple 40 | 3038,Granadilla/Grenadilla Passion fruit 41 | 3039,Physalis/cape gooseberry/ground cherry 42 | 3040,Red (skin color) Pitahaya 43 | 3041,Rambutan 44 | 3042,Mangosteen 45 | 3043,Italia Grapes 46 | 3044,Black Apricots 47 | 3045,Fresh Dates 48 | 3046,Fresh Dates 49 | 3047,Medjool Dates 50 | 3048,Helda/Flat Beans 51 | 3049,Fine Beans 52 | 3050,Dutch White/Winter White Cabbage 53 | 3051,Spring Cabbage/Spring Greens Cabbage 54 | 3052,String Garlic 55 | 3053,Baby Parsnip 56 | 3054,Elongated Peppers (capsicums) 57 | 3055,Elongated Peppers (capsicums) 58 | 3056,Elongated Peppers (capsicums) 59 | 3057,Elongated Peppers (capsicums) 60 | 3058,Elongated Peppers (capsicums) 61 | 3059,Crown Prince Squash 62 | 3060,Vegetable Marrow Squash 63 | 3061,Beef/Beefsteak Tomatoes 64 | 3062,Bay leaves 65 | 3063,Fennel leaves 66 | 3064,Aloe vera leaves 67 | 3065,Small Cameo Apples 68 | 3066,Large Cameo Apples 69 | 3067,Small Swiss Gourmet Apples 70 | 3068,Large Swiss Gourmet Apples 71 | 3069,Small Gravenstein Apples 72 | 3070,Large Gravenstein Apples 73 | 3071,Granny Smith Apples 74 | 3072,Lady Apples 75 | 3073,Macoun Apples 76 | 3074,Greening (RI) Apples 77 | 3075,Baldwin Apples 78 | 3076,Melrose Apples 79 | 3077,Northern Spy Apples 80 | 3078,Liberty Apples 81 | 3079,Purple Asparagus 82 | 3080,Pinkerton Avocados 83 | 3081,Saskatoon Berries 84 | 3082,Crowns Broccoli 85 | 3083,Stalk Brussels sprouts 86 | 3084,Chervil 87 | 3085,Large Indian Corn 88 | 3086,Mini Indian Corn 89 | 3087,Indian Corn 90 | 3088,Red Currants 91 | 3089,Chinese Eggplant (aubergine) 92 | 3090,Thai Eggplant (aubergine) 93 | 3091,Gobo root/burdock 94 | 3092,OroBlanco/Sweetie Grapefruit 95 | 3093,Retailer Assigned Grapes 96 | 3094,Retailer Assigned Grapes 97 | 3095,Multicolor Kale 98 | 3096,Purple/Red/All Other Colors Kohlrabi 99 | 3097,Romaine Lettuce 100 | 3098,Boston Lettuce 101 | 3099,Lotus root 102 | 3100,Gold Honeydew Melon 103 | 3101,Piel de Sapo Melon 104 | 3102,Morel Mushrooms 105 | 3103,Enoki Mushrooms 106 | 3104,RoHo 3615 Apples 107 | 3105,Cashews 108 | 3106,Macadamia 109 | 3107,Medium Navel Oranges 110 | 3108,Medium Valencia Oranges 111 | 3109,Seville (Marmalade type) Oranges 112 | 3110,Navel Oranges 113 | 3111,Red-Fleshed (Solo Sunrise) Papaya/pawpaw 114 | 3112,Meridol Papaya/pawpaw 115 | 3113,Flat White Flesh (Saturn type) Peaches 116 | 3114,Extra Large Green Mango 117 | 3115,Flat Yellow Flesh Peaches 118 | 3116,Small Yellow Flesh Peaches 119 | 3117,Large Yellow Flesh Peaches 120 | 3118,Starkrimson Pears 121 | 3119,"Small Bell, Greenhouse Peppers (capsicums)" 122 | 3120,"Large Bell, Greenhouse Peppers (capsicums)" 123 | 3121,"Bell, Greenhouse Peppers (capsicums)" 124 | 3122,"Bell, Greenhouse Peppers (capsicums)" 125 | 3123,"Bell, Greenhouse Peppers (capsicums)" 126 | 3124,"Bell, Greenhouse Peppers (capsicums)" 127 | 3125,Habanero Peppers (capsicums) 128 | 3126,Retailer Assigned Plumcot (interspecific plum) 129 | 3127,Medium Pomegranate 130 | 3128,Purple Potato 131 | 3129,Pummelo Grapefruit 132 | 3130,Jumbo Pumpkin 133 | 3131,Decorative (Painted) Pumpkin 134 | 3132,White Pumpkin 135 | 3133,White Pumpkin 136 | 3134,Pie Pumpkin Pumpkin 137 | 3135,Ornamental Gourd 138 | 3136,Sapodillo/nispero 139 | 3137,White Sapote 140 | 3138,Black Sapote 141 | 3139,Savory 142 | 3140,Cucuzza Squash 143 | 3141,Opo Squash 144 | 3142,Carnival Squash 145 | 3143,Acorn Squash 146 | 3144,Fall Glo Tangerines/mandarins 147 | 3145,Plum/Italian/Saladette/Roma Tomatoes 148 | 3146,Cherry Tomatoes 149 | 3147,Cherry Tomatoes 150 | 3148,Regular Tomatoes 151 | 3149,Regular Tomatoes 152 | 3150,Cocktail/Intermediate Tomatoes 153 | 3151,"Large Vine Ripe, Regular Tomatoes" 154 | 3152,Melogold Grapefruit 155 | 3153,Medium Delta Seedless Oranges 156 | 3154,Large Delta Seedless Oranges 157 | 3155,Medium Midknight Oranges 158 | 3156,Large Midknight Oranges 159 | 3157,X-Lrg White Grapefruit 160 | 3158,X-Lrg White Grapefruit 161 | 3159,X-Lrg White Grapefruit 162 | 3160,Synonymous with Chinese Broccoli Gai lan 163 | 3161,Baby Gai (gui) choy (chinese or indian mustard) 164 | 3162,Synonymous with Water Spinach Ong choy 165 | 3163,Shanghai Bok choy (pak choi) 166 | 3164,Yu choy 167 | 3165,Treviso Radicchio 168 | 3166,Tuscan Cabbage 169 | 3167,Frisee 170 | 3168,Castlefranco Radicchio 171 | 3169,Catalogna Lettuce 172 | 3170,Retailer Assigned For use with all commodities 173 | 3171,Retailer Assigned For use with all commodities 174 | 3172,Retailer Assigned For use with all commodities 175 | 3173,Retailer Assigned For use with all commodities 176 | 3174,Retailer Assigned For use with all commodities 177 | 3175,Retailer Assigned For use with all commodities 178 | 3176,Retailer Assigned For use with all commodities 179 | 3177,Retailer Assigned For use with all commodities 180 | 3178,Retailer Assigned For use with all commodities 181 | 3179,Retailer Assigned For use with all commodities 182 | 3180,Retailer Assigned For use with all commodities 183 | 3181,Retailer Assigned For use with all commodities 184 | 3182,Retailer Assigned For use with all commodities 185 | 3183,Retailer Assigned For use with all commodities 186 | 3184,Retailer Assigned For use with all commodities 187 | 3185,Retailer Assigned For use with all commodities 188 | 3186,Retailer Assigned For use with all commodities 189 | 3187,Retailer Assigned For use with all commodities 190 | 3188,Retailer Assigned For use with all commodities 191 | 3189,Retailer Assigned For use with all commodities 192 | 3190,Retailer Assigned For use with all commodities 193 | 3191,Retailer Assigned For use with all commodities 194 | 3192,Retailer Assigned For use with all commodities 195 | 3193,Retailer Assigned For use with all commodities 196 | 3194,Retailer Assigned For use with all commodities 197 | 3195,Retailer Assigned For use with all commodities 198 | 3196,Retailer Assigned For use with all commodities 199 | 3197,Retailer Assigned For use with all commodities 200 | 3198,Retailer Assigned For use with all commodities 201 | 3199,Retailer Assigned For use with all commodities 202 | 3200,Retailer Assigned For use with all commodities 203 | 3201,Retailer Assigned For use with all commodities 204 | 3202,Retailer Assigned For use with all commodities 205 | 3203,Retailer Assigned For use with all commodities 206 | 3204,Retailer Assigned For use with all commodities 207 | 3205,Retailer Assigned For use with all commodities 208 | 3206,Retailer Assigned For use with all commodities 209 | 3207,Retailer Assigned For use with all commodities 210 | 3208,Retailer Assigned For use with all commodities 211 | 3209,Retailer Assigned For use with all commodities 212 | 3210,Retailer Assigned For use with all commodities 213 | 3211,Retailer Assigned For use with all commodities 214 | 3212,Retailer Assigned For use with all commodities 215 | 3213,Retailer Assigned For use with all commodities 216 | 3214,Retailer Assigned For use with all commodities 217 | 3215,Retailer Assigned For use with all commodities 218 | 3216,Retailer Assigned For use with all commodities 219 | 3217,Retailer Assigned For use with all commodities 220 | 3218,Retailer Assigned For use with all commodities 221 | 3219,Retailer Assigned For use with all commodities 222 | 3220,Retailer Assigned For use with all commodities 223 | 3221,Retailer Assigned For use with all commodities 224 | 3222,Retailer Assigned For use with all commodities 225 | 3223,Retailer Assigned For use with all commodities 226 | 3224,Retailer Assigned For use with all commodities 227 | 3225,Retailer Assigned For use with all commodities 228 | 3226,Retailer Assigned For use with all commodities 229 | 3227,Retailer Assigned For use with all commodities 230 | 3228,Retailer Assigned For use with all commodities 231 | 3229,Retailer Assigned For use with all commodities 232 | 3230,Retailer Assigned For use with all commodities 233 | 3231,Retailer Assigned For use with all commodities 234 | 3232,Retailer Assigned For use with all commodities 235 | 3233,Retailer Assigned For use with all commodities 236 | 3234,Retailer Assigned For use with all commodities 237 | 3235,Retailer Assigned For use with all commodities 238 | 3236,Retailer Assigned For use with all commodities 239 | 3237,Retailer Assigned For use with all commodities 240 | 3238,Retailer Assigned For use with all commodities 241 | 3239,Retailer Assigned For use with all commodities 242 | 3240,Retailer Assigned For use with all commodities 243 | 3241,Retailer Assigned For use with all commodities 244 | 3242,Retailer Assigned For use with all commodities 245 | 3243,Retailer Assigned For use with all commodities 246 | 3244,Retailer Assigned For use with all commodities 247 | 3245,Retailer Assigned For use with all commodities 248 | 3246,Retailer Assigned For use with all commodities 249 | 3247,Retailer Assigned For use with all commodities 250 | 3248,Retailer Assigned For use with all commodities 251 | 3249,Retailer Assigned For use with all commodities 252 | 3250,Retailer Assigned For use with all commodities 253 | 3251,Retailer Assigned For use with all commodities 254 | 3252,Retailer Assigned For use with all commodities 255 | 3253,Retailer Assigned For use with all commodities 256 | 3254,Retailer Assigned For use with all commodities 257 | 3255,Retailer Assigned For use with all commodities 258 | 3256,Retailer Assigned For use with all commodities 259 | 3257,Retailer Assigned For use with all commodities 260 | 3258,Retailer Assigned For use with all commodities 261 | 3259,Retailer Assigned For use with all commodities 262 | 3260,Retailer Assigned For use with all commodities 263 | 3261,Retailer Assigned For use with all commodities 264 | 3262,Retailer Assigned For use with all commodities 265 | 3263,Retailer Assigned For use with all commodities 266 | 3264,Retailer Assigned For use with all commodities 267 | 3265,Retailer Assigned For use with all commodities 268 | 3266,Retailer Assigned For use with all commodities 269 | 3267,Retailer Assigned For use with all commodities 270 | 3268,Retailer Assigned For use with all commodities 271 | 3269,Retailer Assigned For use with all commodities 272 | 3270,Retailer Assigned For use with all commodities 273 | 3271,Virginia Gold Apples 274 | 3272,Sommerfeld Apples 275 | 3273,Golden Beets 276 | 3274,Fresh Prunes 277 | 3275,Yellow (nyAH-may) Name 278 | 3276,White (nyAH-may) Name 279 | 3277,Baby Broccoli 280 | 3278,Plumcot (interspecific plum) 281 | 3279,Golden Kiwifruit 282 | 3280,Jumbo Regular Kiwifruit 283 | 3281,Orange Seedless Watermelon 284 | 3282,Plum/Italian/Saladette/Roma on the vine Tomatoes 285 | 3283,Honeycrisp Apples 286 | 3284,Extra Large Red Delicious Apples 287 | 3285,Extra Large Golden Delicious Apples 288 | 3286,Sweet red Italian Onions 289 | 3287,Hawaiian plantain Bananas 290 | 3288,Retailer Assigned Sweet potato/yam/kumara 291 | 3289,Sprite Melon 292 | 3290,Large Aurora/Southern Rose Apples 293 | 3291,Small Boskoop/Belle de Boskoop Apples 294 | 3292,Large Boskoop/Belle de Boskoop Apples 295 | 3293,Small Scifresh Apples 296 | 3294,Large Scifresh Apples 297 | 3295,Small Sciearly Apples 298 | 3296,Large Sciearly Apples 299 | 3297,Scired Apples 300 | 3298,Redfield Apples 301 | 3299,Small Sonya Apples 302 | 3300,Large Sonya Apples 303 | 3301,Large Cripps Red Apples 304 | 3302,Large Regular Apricots 305 | 3303,Babaco 306 | 3304,Loganberries Berries 307 | 3305,Black Currants 308 | 3306,Medium Charentais Melon 309 | 3307,Extra Large Charentais Melon 310 | 3308,Watermelon 311 | 3309,Lima Oranges 312 | 3310,Pera Oranges 313 | 3311,Curuba/Banana Passion fruit 314 | 3312,Granadilla Passion fruit 315 | 3313,Small White Flesh Peaches 316 | 3314,Large White Flesh Peaches 317 | 3315,Small Scilate Apples 318 | 3316,Carmen Pears 319 | 3317,Angelys Pears 320 | 3318,Large Passe Crassane Pears 321 | 3319,Yellow (skin color) Pitahaya 322 | 3320,Romanesco/Broccoflower/Caulibroc Cauliflower 323 | 3321,With leaves attached Celery root/celeriac 324 | 3322,Choy sum/pak choi sum 325 | 3323,Baby Choy sum/pak choi sum 326 | 3324,Red Escarole/batavian chicory 327 | 3325,Lollo Bionda/Coral Lettuce 328 | 3326,Lollo Rossa/Coral Lettuce 329 | 3327,Mignonette (Compact red-tinged butterhead varieties) Lettuce 330 | 3328,"Mixed small-leaf salad (eg Sucrine, Mesclun, Rocket/Arugula) Lettuce" 331 | 3329,Oak Leaf Lettuce 332 | 3330,Oak Leaf Lettuce 333 | 3331,Red Fresh Onions 334 | 3332,Baby Spinach 335 | 3333,Small Red/Orangy White Flesh Sweet potato/yam/kumara 336 | 3334,Large Red/Orangy White Flesh Sweet potato/yam/kumara 337 | 3335,Cocktail/Intermediate Tomatoes 338 | 3336,Cocktail/Intermediate Tomatoes 339 | 3337,(Dried Fruit) Figs 340 | 3338,Anise 341 | 3339,Belchard Apples 342 | 3340,Bertanne/Golden Russet Apples 343 | 3341,Charles Ross Apples 344 | 3342,Delblush Apples 345 | 3343,Dessert Apples 346 | 3344,Small Gloster Apples 347 | 3345,Large Gloster Apples 348 | 3346,Holstein Apples 349 | 3347,Laxtons Fortune Apples 350 | 3348,Lord Lambourne Apples 351 | 3349,Michaelmas Red Apples 352 | 3350,Small Reine des Reinettes/King of the Pippins Apples 353 | 3351,Large Reine des Reinettes/King of the Pippins Apples 354 | 3352,"Reinettes and ""Heritage"" varieties Apples" 355 | 3353,St Edmunds Pippin Apples 356 | 3354,Ripe/Ready-to-Eat Avocados 357 | 3355,Strawberries Berries 358 | 3356,Strawberries Berries 359 | 3357,Small Regular/Red/Black Cherries 360 | 3358,Large Regular/Red/Black Cherries 361 | 3359,Chasselas Grapes 362 | 3360,Muscat de Hambourg Grapes 363 | 3361,Without p/harvest treatment Grapefruit 364 | 3362,Without postharvest treatment Lemons 365 | 3363,Bowen & Kensington Pride Mango 366 | 3364,R2E2 (ArtwoEetwo) Mango 367 | 3365,Ripe/Ready-to-Eat Mango 368 | 3366,MadroÑa 369 | 3367,Glasshouse - Netted varieties Melon 370 | 3368,Ogen Melon 371 | 3369,Nectavigne (Red Flesh) Nectarine 372 | 3370,Maltaise Oranges 373 | 3371,Salustiana Oranges 374 | 3372,Navelate (and other late Navel varieties) Oranges 375 | 3373,Navelina (incl. Newhall) Oranges 376 | 3374,Without postharvest treatment Oranges 377 | 3375,de Vigne & Sanguine (Red Flesh) Peaches 378 | 3376,Alexander Lucas Pears 379 | 3377,Louise Bonne Pears 380 | 3378,Santa Maria Pears 381 | 3379,Mini Pineapple 382 | 3380,Perola Pineapple 383 | 3381,Soursop 384 | 3382,Sugar apple 385 | 3383,Small Clementine Tangerines/mandarins 386 | 3384,Medium Clementine Tangerines/mandarins 387 | 3385,Large Clementine Tangerines/mandarins 388 | 3386,Clementine Tangerines/mandarins 389 | 3387,Clementine Tangerines/mandarins 390 | 3388,Satsuma Tangerines/mandarins 391 | 3389,Satsuma Tangerines/mandarins 392 | 3390,Arracach 393 | 3391,Rouge Salambo (Red) Artichokes 394 | 3392,Green Asparagus 395 | 3393,White Asparagus 396 | 3394,Purple Asparagus 397 | 3395,Red Belgian endive (witloof chicory) 398 | 3396,"Savoy, Red Cabbage" 399 | 3397,Summer Cabbage Cabbage 400 | 3398,Chickpeas/Garbanzo Chickpeas 401 | 3399,Regular Garlic 402 | 3400,Regular Garlic 403 | 3401,One-clove types Garlic 404 | 3402,Regular Leeks 405 | 3403,Baby Leeks 406 | 3404,Cep Mushrooms 407 | 3405,Fairy Ring Champignon Mushrooms 408 | 3406,Grey Mushrooms 409 | 3407,Grisette Mushrooms 410 | 3408,Horn of Plenty/Black Trumpet Mushrooms 411 | 3409,Pioppino Mushrooms 412 | 3410,Saffron Milk-Cap Mushrooms 413 | 3411,Sheep Polypore Mushrooms 414 | 3412,Yellow/Brown Fresh Onions 415 | 3413,Tabasco Peppers (capsicums) 416 | 3414,Baking Potato 417 | 3415,Baking Potato 418 | 3416,Bunch Rhubarb 419 | 3417,New Zealand Spinach Spinach 420 | 3418,Zucchini/Courgette Squash 421 | 3419,Borage 422 | 3421,Mini Seedless Watermelon 423 | 3422,InterSpecific Apricots 424 | 3423,Heirloom Tomatoes 425 | 3424,Purple/Red Carrots 426 | 3425,Small Ellendale Tangerines/mandarins 427 | 3426,Medium Ellendale Tangerines/mandarins 428 | 3427,Large Ellendale Tangerines/mandarins 429 | 3428,Small Honey/Murcott Tangerines/mandarins 430 | 3429,Medium Honey/Murcott Tangerines/mandarins 431 | 3430,Large Honey/Murcott Tangerines/mandarins 432 | 3431,Small Imperial Tangerines/mandarins 433 | 3432,Medium Imperial Tangerines/mandarins 434 | 3433,Large Imperial Tangerines/mandarins 435 | 3434,Tosca Pears 436 | 3435,Pinova Apples 437 | 3436,Orange Cauliflower 438 | 3437,Flat Yellow Nectarine 439 | 3438,Ambrosia Apples 440 | 3439,White Flesh Flat Nectarine 441 | 3440,Large Pomegranate 442 | 3600,Antares Apples 443 | 3601,Huaguan Apples 444 | 3602,Belgica Apples 445 | 3603,Minneiska Apples 446 | 3604,Emmons Apples 447 | 3605,Nicoter Apples 448 | 3606,Sweet Sensation Pears 449 | 3607,Mariri Red Apples 450 | 3608,Large Sciros Apples 451 | 3609,Red Plumcot (interspecific plum) 452 | 3610,Green Plumcot (interspecific plum) 453 | 3611,Black Plumcot (interspecific plum) 454 | 3612,Nicogreen Apples 455 | 3613,Fuji Brak Apples 456 | 3614,Red Apricots 457 | 3615,Civni Apples 458 | 3616,Large Scilate Apples 459 | 3617,Seedless Lemons 460 | 3618,Opal Apples 461 | 3619,Milwa Apples 462 | 3620,Plumac Apples 463 | 3621,Francis Mango 464 | 3622,Honey Green Melon 465 | 3623,Hami Melon 466 | 3624,Korean Melon 467 | 3625,Minnewashta Apples 468 | 3626,Meyer Lemons 469 | 3627,Large PremA17 Apples 470 | 3628,PremA280 Apples 471 | 3629,CIVG198 Apples 472 | 3630,Co-op 43 Apples 473 | 3631,Pink Pumpkin 474 | 3632,Dekopon Tangerines/mandarins 475 | 4011,Bananas 476 | 4012,Large Navel Oranges 477 | 4013,Small Navel Oranges 478 | 4014,Small Valencia Oranges 479 | 4015,Small Red Delicious Apples 480 | 4016,Large Red Delicious Apples 481 | 4017,Large Granny Smith Apples 482 | 4018,Large Granny Smith Apples 483 | 4019,Large McIntosh Apples 484 | 4020,Large Golden Delicious Apples 485 | 4021,Small Golden Delicious Apples 486 | 4022,White/Green Seedless Grapes 487 | 4023,Red Seedless Grapes 488 | 4024,Small Bartlett/Williams/WBC Pears 489 | 4025,Small Anjou Pears 490 | 4026,Small Bosc/Beurre Bosc Pears 491 | 4027,Small Ruby/Red/Pink Grapefruit 492 | 4028,Pint Strawberries Berries 493 | 4029,Small Pineapple 494 | 4030,Regular Kiwifruit 495 | 4031,Seeded Watermelon 496 | 4032,Seedless Watermelon 497 | 4033,Small Lemons 498 | 4034,Large Honeydew/White Honeydew Melon 499 | 4035,Small Yellow Flesh Nectarine 500 | 4036,Large Yellow Flesh Nectarine 501 | 4037,Small Yellow Flesh Peaches 502 | 4038,Large Yellow Flesh Peaches 503 | 4039,Small Black Plums 504 | 4040,Large Black Plums 505 | 4041,Small Red Plums 506 | 4042,Large Red Plums 507 | 4043,Small Yellow Flesh Peaches 508 | 4044,Large Yellow Flesh Peaches 509 | 4045,Regular/Red/Black Cherries 510 | 4046,Small Hass Avocados 511 | 4047,Small Ruby/Red/Pink Grapefruit 512 | 4048,"Regular (incl. Persian, Tahiti & Bearss) Limes" 513 | 4049,Small Cantaloupe/Rockmelon Melon 514 | 4050,Large Cantaloupe/Rockmelon Melon 515 | 4051,Small Red Mango 516 | 4052,Small Regular Papaya/pawpaw 517 | 4053,Large Lemons 518 | 4054,Raspberries Berries 519 | 4055,Tangerines/mandarins 520 | 4056,Blue/Black Seedless Grapes 521 | 4057,Small Haralson Apples 522 | 4058,Large Haralson Apples 523 | 4060,Broccoli 524 | 4061,Iceberg Lettuce 525 | 4062,Green/Ridge/Short Cucumber 526 | 4063,Small Regular Tomatoes 527 | 4064,Large Regular Tomatoes 528 | 4065,"Large Bell, Field Grown Peppers (capsicums)" 529 | 4066,Green/French Beans 530 | 4067,Zucchini/Courgette Squash 531 | 4068,Green (Scallions)/Spring Onions 532 | 4069,Green Cabbage 533 | 4070,Small Bunch Celery 534 | 4071,Small Bunch Celery 535 | 4072,Russet Potato 536 | 4073,Red Potato 537 | 4074,Small Red/Orangy Red Flesh Sweet potato/yam/kumara 538 | 4075,Red Leaf Lettuce 539 | 4076,Green Leaf Lettuce 540 | 4077,"Sweet Corn, White Corn" 541 | 4078,"Sweet Corn, Yellow Corn" 542 | 4079,Small Cauliflower 543 | 4080,Small Green Asparagus 544 | 4081,Regular Eggplant (aubergine) 545 | 4082,Red Onions 546 | 4083,White Potato 547 | 4084,Large Artichokes 548 | 4085,Large Regular Mushrooms 549 | 4086,Yellow Zucchini/Gold Bar/Yellow Courgette Squash 550 | 4087,Plum/Italian/Saladette/Roma Tomatoes 551 | 4088,Red Bell Peppers 552 | 4089,Bunched Red Radish 553 | 4090,Regular/Bunched Spinach 554 | 4091,White Sweet potato/yam/kumara 555 | 4092,Chinese Snow Pea/Pea Pod/Mange Tout Peas 556 | 4093,Large Yellow/Brown Onions 557 | 4094,Bunch Carrots 558 | 4095,Yellow Turnip 559 | 4096,Large Ginger Gold Apples 560 | 4097,Small Ginger Gold Apples 561 | 4098,Small Akane Apples 562 | 4099,Large Akane Apples 563 | 4100,Small Fireside Apples 564 | 4101,Small Braeburn Apples 565 | 4102,Large Fireside Apples 566 | 4103,Large Braeburn Apples 567 | 4104,Small Cortland Apples 568 | 4105,Cox Orange Pippin Apples 569 | 4106,Large Cortland Apples 570 | 4107,Crab Apples 571 | 4108,Small Crispin/Mutsu Apples 572 | 4109,Small Crispin/Mutsu Apples 573 | 4110,Large Crispin/Mutsu Apples 574 | 4111,Large Crispin/Mutsu Apples 575 | 4112,Small Regent Apples 576 | 4113,Small Criterion Apples 577 | 4114,Large Regent Apples 578 | 4115,Large Criterion Apples 579 | 4116,Small Early Apples 580 | 4117,Small Early Apples 581 | 4118,Large Early Apples 582 | 4119,Large Early Apples 583 | 4120,Fiesta Apples 584 | 4121,Small Elstar Apples 585 | 4122,Small Sciros Apples 586 | 4123,Large Elstar Apples 587 | 4124,Small Empire Apples 588 | 4125,Small Empire Apples 589 | 4126,Large Empire Apples 590 | 4127,Large Empire Apples 591 | 4128,Small Cripps Pink Apples 592 | 4129,Small Fuji Apples 593 | 4130,Large Cripps Pink Apples 594 | 4131,Large Fuji Apples 595 | 4132,Small Gala Apples 596 | 4133,Small Gala Apples 597 | 4134,Large Gala Apples 598 | 4135,Large Gala Apples 599 | 4136,Small Golden Delicious Apples 600 | 4137,Large Golden Delicious Apples 601 | 4138,Small Granny Smith Apples 602 | 4139,Small Granny Smith Apples 603 | 4140,Small Idared Apples 604 | 4141,Small Jonamac Apples 605 | 4142,Large Idared Apples 606 | 4143,Large Jonamac Apples 607 | 4144,Small Jonagold Apples 608 | 4145,Small Jonagold Apples 609 | 4146,Large Jonagold Apples 610 | 4147,Large Jonagold Apples 611 | 4148,Small Jonathan Apples 612 | 4149,Small Jonathan Apples 613 | 4150,Large Jonathan Apples 614 | 4151,Large Jonathan Apples 615 | 4152,Small McIntosh Apples 616 | 4153,Small McIntosh Apples 617 | 4154,Large McIntosh Apples 618 | 4155,Small Paulared Apples 619 | 4156,Small Gravenstein Apples 620 | 4157,Large Paulared Apples 621 | 4158,Large Gravenstein Apples 622 | 4159,Vidalia Onions 623 | 4160,Small Pippin Apples 624 | 4161,Texas Sweet Onions 625 | 4162,Large Pippin Apples 626 | 4163,Walla Walla Onions 627 | 4164,Maui Onions 628 | 4165,California Sweet Onions 629 | 4166,Other Sweet Onions 630 | 4167,Small Red Delicious Apples 631 | 4168,Large Red Delicious Apples 632 | 4169,Small Rome Apples 633 | 4170,Small Rome Apples 634 | 4171,Large Rome Apples 635 | 4172,Large Rome Apples 636 | 4173,Small Royal Gala Apples 637 | 4174,Large Royal Gala Apples 638 | 4176,Southern Snap Apples 639 | 4177,Small Spartan Apples 640 | 4178,Small Spartan Apples 641 | 4179,Large Spartan Apples 642 | 4180,Large Spartan Apples 643 | 4181,Small Stayman Apples 644 | 4182,Sturmer Pippin Apples 645 | 4183,Large Stayman Apples 646 | 4185,Small York Apples 647 | 4186,Small Yellow Bananas 648 | 4187,Large York Apples 649 | 4188,"Small White Flesh, Tree Ripened, Ready-to-eat Nectarine" 650 | 4189,Small Winesap Apples 651 | 4190,Small Winesap Apples 652 | 4191,Large Winesap Apples 653 | 4192,Large Winesap Apples 654 | 4193,Retailer Assigned Apples 655 | 4194,Retailer Assigned Apples 656 | 4195,Retailer Assigned Apples 657 | 4196,Retailer Assigned Apples 658 | 4197,Retailer Assigned Apples 659 | 4198,Retailer Assigned Apples 660 | 4199,Retailer Assigned Apples 661 | 4200,Retailer Assigned Apples 662 | 4201,Retailer Assigned Apples 663 | 4202,Retailer Assigned Apples 664 | 4203,Retailer Assigned Apples 665 | 4204,Retailer Assigned Apples 666 | 4205,Retailer Assigned Apples 667 | 4206,Retailer Assigned Apples 668 | 4207,Retailer Assigned Apples 669 | 4208,Retailer Assigned Apples 670 | 4209,Retailer Assigned Apples 671 | 4210,Retailer Assigned Apples 672 | 4211,Retailer Assigned Apples 673 | 4212,Retailer Assigned Apples 674 | 4213,Retailer Assigned Apples 675 | 4214,Retailer Assigned Apples 676 | 4215,Retailer Assigned Apples 677 | 4216,Retailer Assigned Apples 678 | 4217,Retailer Assigned Apples 679 | 4218,Small Regular Apricots 680 | 4219,Retailer Assigned Apricots 681 | 4220,Atemoyas 682 | 4221,Small Green Avocados 683 | 4222,Small Green Avocados 684 | 4223,Large Green Avocados 685 | 4224,Large Green Avocados 686 | 4225,Large Hass Avocados 687 | 4226,Cocktail/Seedless Avocados 688 | 4227,Retailer Assigned Avocados 689 | 4228,Retailer Assigned Avocados 690 | 4229,Burro Bananas 691 | 4230,Dominique Bananas 692 | 4231,Green Bananas 693 | 4232,Leaves Bananas 694 | 4233,Manzano/Apple Bananas 695 | 4234,Nino Bananas 696 | 4235,Plantain/Macho Bananas 697 | 4236,Red Bananas 698 | 4237,Retailer Assigned Bananas 699 | 4238,Retailer Assigned Bananas 700 | 4239,Blackberries Berries 701 | 4240,Blueberries Berries 702 | 4241,Boysenberries Berries 703 | 4242,Cranberries Berries 704 | 4243,Gooseberries Berries 705 | 4244,Raspberries Berries 706 | 4245,Raspberries Berries 707 | 4246,Pint Strawberries Berries 708 | 4247,Quart Strawberries Berries 709 | 4248,Quart Strawberries Berries 710 | 4249,Bulk 3-pack (3 pints) Strawberries Berries 711 | 4250,Bulk 3-pack (3 pints) Strawberries Berries 712 | 4251,Long-stemmed Strawberries Berries 713 | 4252,Retailer Assigned Berries 714 | 4253,Retailer Assigned Berries 715 | 4254,Breadfruit 716 | 4255,Cactus pear (prickly pear) 717 | 4256,Carambola (starfruit) 718 | 4257,Cherimoya 719 | 4258,Golden/Rainier/White Cherries 720 | 4259,Retailer Assigned Cherries 721 | 4260,In Husk/Waternut Coconuts 722 | 4261,Husked Coconuts 723 | 4262,Retailer Assigned Coconuts 724 | 4263,Fresh Dates 725 | 4264,Retailer Assigned Dates 726 | 4265,Feijoa 727 | 4266,Black Figs 728 | 4267,Brown Figs 729 | 4268,White/Green Figs 730 | 4269,Retailer Assigned Figs 731 | 4270,Blue/Black Seeded Grapes 732 | 4271,Champagne Grapes 733 | 4272,Concord Grapes 734 | 4273,Red Seeded Grapes 735 | 4274,White/Green Seeded Grapes 736 | 4275,Retailer Assigned Grapes 737 | 4276,Retailer Assigned Grapes 738 | 4277,Retailer Assigned Grapes 739 | 4278,Retailer Assigned Grapes 740 | 4279,Pummelo Grapefruit 741 | 4280,Small Ruby/Red/Pink Grapefruit 742 | 4281,Large Ruby/Red/Pink Grapefruit 743 | 4282,Large Ruby/Red/Pink Grapefruit 744 | 4283,Large Ruby/Red/Pink Grapefruit 745 | 4284,Small Deep Red Grapefruit 746 | 4285,Small Deep Red Grapefruit 747 | 4286,Sm Deep Red Grapefruit 748 | 4287,Large Deep Red Grapefruit 749 | 4288,Large Deep Red Grapefruit 750 | 4289,Lrg Deep Red Grapefruit 751 | 4290,Small White Grapefruit 752 | 4291,Small White Grapefruit 753 | 4292,Small White Grapefruit 754 | 4293,Large White Grapefruit 755 | 4294,Large White Grapefruit 756 | 4295,Large White Grapefruit 757 | 4296,Retailer Assigned Grapefruit 758 | 4297,Retailer Assigned Grapefruit 759 | 4298,Retailer Assigned Grapefruit 760 | 4299,Guava 761 | 4300,Homli fruit 762 | 4301,Retailer Assigned Kiwifruit 763 | 4302,Kiwano (horned melon) 764 | 4303,Kumquat 765 | 4304,Retailer Assigned Lemons 766 | 4305,Key (incl. Mexican & West Indian) Limes 767 | 4306,Retailer Assigned Limes 768 | 4307,Longan 769 | 4308,Loquats 770 | 4309,Lychees 771 | 4310,Mamey 772 | 4311,Small Green Mango 773 | 4312,Small Yellow Mango 774 | 4313,Retailer Assigned Mango 775 | 4314,Retailer Assigned Mango 776 | 4315,Retailer Assigned Mango 777 | 4316,Retailer Assigned Mango 778 | 4317,Canary/Yellow Honeydew Melon 779 | 4318,Small Cantaloupe/Muskmelon Melon 780 | 4319,Large Cantaloupe/Muskmelon Melon 781 | 4320,Casaba Melon 782 | 4321,Cinnabar Melon 783 | 4322,Crenshaw Melon 784 | 4323,Bulk Strawberries Berries 785 | 4324,French Afternoon Melon 786 | 4325,French Breakfast Melon 787 | 4326,Galia Melon 788 | 4327,Orange Flesh/Cantaline Melon 789 | 4328,Limequats 790 | 4329,Small Honeydew/White Honeydew Melon 791 | 4330,Mayan Melon 792 | 4331,Mickey Lee / Sugar Baby Watermelon 793 | 4332,Muskmelon Melon 794 | 4333,Pepino Melon 795 | 4334,Persian Melon 796 | 4335,Prince Melon 797 | 4336,Santa Claus Melon 798 | 4337,Saticoy Melon 799 | 4338,Sharlin Melon 800 | 4339,Spanish/Tendral Melon 801 | 4340,Yellow Seeded Watermelon 802 | 4341,Yellow Seedless Watermelon 803 | 4342,Retailer Assigned (includes pre-cut melons) Melon 804 | 4343,Retailer Assigned (includes pre-cut melons) Melon 805 | 4344,Retailer Assigned (includes pre-cut melons) Melon 806 | 4345,Retailer Assigned (includes pre-cut melons) Melon 807 | 4346,Retailer Assigned (includes pre-cut melons) Melon 808 | 4347,Retailer Assigned (includes pre-cut melons) Melon 809 | 4348,Retailer Assigned (includes pre-cut melons) Melon 810 | 4349,Retailer Assigned (includes pre-cut melons) Melon 811 | 4350,Retailer Assigned (includes pre-cut melons) Melon 812 | 4351,Retailer Assigned (includes pre-cut melons) Melon 813 | 4352,Retailer Assigned (includes pre-cut melons) Melon 814 | 4353,Retailer Assigned (includes pre-cut melons) Melon 815 | 4354,Retailer Assigned (includes pre-cut melons) Melon 816 | 4355,Retailer Assigned (includes pre-cut melons) Melon 817 | 4356,Retailer Assigned (includes pre-cut melons) Melon 818 | 4357,Retailer Assigned (includes pre-cut melons) Melon 819 | 4358,Retailer Assigned (includes pre-cut melons) Melon 820 | 4359,Retailer Assigned (includes pre-cut melons) Melon 821 | 4360,Retailer Assigned (includes pre-cut melons) Melon 822 | 4361,Retailer Assigned (includes pre-cut melons) Melon 823 | 4362,Retailer Assigned (includes pre-cut melons) Melon 824 | 4363,Retailer Assigned (includes pre-cut melons) Melon 825 | 4364,Retailer Assigned (includes pre-cut melons) Melon 826 | 4365,Retailer Assigned (includes pre-cut melons) Melon 827 | 4366,Retailer Assigned (includes pre-cut melons) Melon 828 | 4367,Retailer Assigned (includes pre-cut melons) Melon 829 | 4368,Retailer Assigned (includes pre-cut melons) Melon 830 | 4369,Retailer Assigned (includes pre-cut melons) Melon 831 | 4370,Retailer Assigned (includes pre-cut melons) Melon 832 | 4371,Retailer Assigned (includes pre-cut melons) Melon 833 | 4372,Retailer Assigned (includes pre-cut melons) Melon 834 | 4373,Retailer Assigned (includes pre-cut melons) Melon 835 | 4374,Retailer Assigned (includes pre-cut melons) Melon 836 | 4375,Retailer Assigned (includes pre-cut melons) Melon 837 | 4376,Retailer Assigned (includes pre-cut melons) Melon 838 | 4377,"Small Yellow Flesh, Tree Ripened, Ready-to-eat Nectarine" 839 | 4378,"Large Yellow Flesh, Tree Ripened, Ready-to-eat Nectarine" 840 | 4379,Retailer Assigned Nectarine 841 | 4380,Retailer Assigned Nectarine 842 | 4381,Blood Oranges 843 | 4382,Juice Oranges 844 | 4383,Minneola Tangelo 845 | 4384,Small Navel Oranges 846 | 4385,Large Navel Oranges 847 | 4386,Small Temple Oranges 848 | 4387,Large Temple Oranges 849 | 4388,Large Valencia Oranges 850 | 4388,Large Valencia Oranges 851 | 4389,Retailer Assigned Oranges 852 | 4390,Retailer Assigned Oranges 853 | 4391,Retailer Assigned Oranges 854 | 4392,Retailer Assigned Oranges 855 | 4393,Retailer Assigned Oranges 856 | 4394,Large Regular Papaya/pawpaw 857 | 4395,Cooking/Mexican Papaya/pawpaw 858 | 4396,Retailer Assigned Papaya/pawpaw 859 | 4397,Purple Passion fruit 860 | 4398,Retailer Assigned Passion fruit 861 | 4399,Indian Peaches 862 | 4400,Small White Flesh Peaches 863 | 4401,Large White Flesh Peaches 864 | 4402,Small Yellow Flesh Peaches 865 | 4403,Large Yellow Flesh Peaches 866 | 4404,Retailer Assigned Peaches 867 | 4405,Retailer Assigned Peaches 868 | 4406,Asian/Nashi Pears 869 | 4407,Asian/Nashi Pears 870 | 4408,Asian/Nashi Pears 871 | 4409,Large Bartlett/Williams/WBC Pears 872 | 4410,Bartlett Pears 873 | 4411,Small Bosc/Beurre Bosc Pears 874 | 4412,Large Bosc/Beurre Bosc Pears 875 | 4413,Large Bosc/Beurre Bosc Pears 876 | 4414,Comice/ Doyenne du Comice Pears 877 | 4415,Red Pears 878 | 4416,Large Anjou Pears 879 | 4417,Anjou Pears 880 | 4418,Forelle/Corella Pears 881 | 4419,French Pears 882 | 4420,King Royal Pears 883 | 4421,Packham/Packhams Triumph Pears 884 | 4422,Seckel Pears 885 | 4423,Tree Ripened Pears 886 | 4424,Winter Nelis/Honey Pears 887 | 4425,Retailer Assigned Pears 888 | 4426,Retailer Assigned Pears 889 | 4427,Regular (American Persimmon) Persimmon 890 | 4428,Japanese/Sharonfruit (Kaki) Persimmon 891 | 4429,Retailer Assigned Persimmon 892 | 4430,Large Pineapple 893 | 4431,Small Jet Fresh Pineapple 894 | 4432,Large Jet Fresh Pineapple 895 | 4433,Retailer Assigned Pineapple 896 | 4434,Small Green Plums 897 | 4435,Large Green Plums 898 | 4436,Italian Prune/Sugar Plums 899 | 4437,Small Purple Plums 900 | 4438,Large Purple Plums 901 | 4439,Small Tree Ripened Plums 902 | 4440,Large Tree Ripened Plums 903 | 4441,Small Yellow Plums 904 | 4442,Large Yellow Plums 905 | 4443,Retailer Assigned Plums 906 | 4444,Retailer Assigned Plums 907 | 4445,Small Pomegranate 908 | 4446,Retailer Assigned Pomegranate 909 | 4447,Quince 910 | 4448,Tamarindo 911 | 4449,Sunburst Tangerines/mandarins 912 | 4450,Clementine (includes Fortune) Tangerines/mandarins 913 | 4451,Dancy Tangerines/mandarins 914 | 4452,Fairchild Tangerines/mandarins 915 | 4453,Honey/Murcott Tangerines/mandarins 916 | 4454,Kinnow Tangerines/mandarins 917 | 4455,Mandarin/Royal Tangerines/mandarins 918 | 4456,Tangelo 919 | 4457,Retailer Assigned Tangerines/mandarins 920 | 4458,Retailer Assigned Tangerines/mandarins 921 | 4459,Jamaican Tangelo 922 | 4460,Retailer Assigned For use with all commodities 923 | 4461,Retailer Assigned For use with all commodities 924 | 4462,Retailer Assigned For use with all commodities 925 | 4463,Retailer Assigned For use with all commodities 926 | 4464,Retailer Assigned For use with all commodities 927 | 4465,Retailer Assigned For use with all commodities 928 | 4466,Retailer Assigned For use with all commodities 929 | 4467,Retailer Assigned For use with all commodities 930 | 4468,Retailer Assigned For use with all commodities 931 | 4469,Retailer Assigned For use with all commodities 932 | 4470,Salad bar 933 | 4471,Retailer Assigned Other fruits 934 | 4472,Retailer Assigned Other fruits 935 | 4473,Retailer Assigned Other fruits 936 | 4474,Retailer Assigned Other fruits 937 | 4475,Retailer Assigned Other fruits 938 | 4476,Retailer Assigned Other fruits 939 | 4477,Retailer Assigned Other fruits 940 | 4478,Retailer Assigned Other fruits 941 | 4479,Retailer Assigned Other fruits 942 | 4480,Retailer Assigned Other fruits 943 | 4481,Retailer Assigned Other fruits 944 | 4482,Retailer Assigned Other fruits 945 | 4483,Retailer Assigned Other fruits 946 | 4484,Retailer Assigned Other fruits 947 | 4485,Retailer Assigned Other fruits 948 | 4486,Retailer Assigned Other fruits 949 | 4487,Retailer Assigned Other fruits 950 | 4488,Retailer Assigned Other fruits 951 | 4489,Retailer Assigned Other fruits 952 | 4490,Retailer Assigned Other fruits 953 | 4491,X-Lrg Ruby/Red/Pink Grapefruit 954 | 4492,X-Lrg Ruby/Red/Pink Grapefruit 955 | 4493,X-Lrg Ruby/Red/Pink Grapefruit 956 | 4494,X-Lrg Deep Red Grapefruit 957 | 4495,X-Lrg Deep Red Grapefruit 958 | 4496,X-Lrg Deep Red Grapefruit 959 | 4497,Sugraone/Autumn Seedless Grapes 960 | 4498,White/Green Seedless Grapes 961 | 4499,Crimson/Majestic Grapes 962 | 4500,Retailer Assigned Other vegetables 963 | 4501,Retailer Assigned Other vegetables 964 | 4502,Retailer Assigned Other vegetables 965 | 4503,Retailer Assigned Other vegetables 966 | 4504,Retailer Assigned Other vegetables 967 | 4505,Retailer Assigned Other vegetables 968 | 4506,Retailer Assigned Other vegetables 969 | 4507,Retailer Assigned Other vegetables 970 | 4508,Retailer Assigned Other vegetables 971 | 4509,Retailer Assigned Other vegetables 972 | 4510,Retailer Assigned Other vegetables 973 | 4511,Retailer Assigned Other vegetables 974 | 4512,Retailer Assigned Other vegetables 975 | 4513,Retailer Assigned Other vegetables 976 | 4514,Alfalfa sprouts 977 | 4515,Florence/Sweet Fennel/Fennel Bulb Fennel 978 | 4516,Small Artichokes 979 | 4517,Small Purple Artichokes 980 | 4518,Large Purple Artichokes 981 | 4519,Baby/Cocktail Artichokes 982 | 4520,Retailer Assigned Artichokes 983 | 4521,Large Green Asparagus 984 | 4522,Small White Asparagus 985 | 4523,Large White Asparagus 986 | 4524,Tips Asparagus 987 | 4525,Retailer Assigned Asparagus 988 | 4526,Retailer Assigned Asparagus 989 | 4527,Chinese Long/Snake Beans 990 | 4528,Fava/Broad Beans 991 | 4529,Lima Beans 992 | 4530,Pole/Runner/Stick Beans 993 | 4531,Purple Hull Beans 994 | 4532,Shell Beans 995 | 4533,Wax/Yellow Beans 996 | 4534,Winged Beans 997 | 4535,Retailer Assigned Beans 998 | 4536,Mung Bean Sprouts Bean sprouts 999 | 4537,Baby Golden Beets 1000 | 4538,Baby Red Beets 1001 | 4539,Bunch Beets 1002 | 4540,Loose Beets 1003 | 4541,Retailer Assigned Beets 1004 | 4542,Beet greens 1005 | 4543,Belgian endive (witloof chicory) 1006 | 4544,Small/Baby Bok choy (pak choi) 1007 | 4545,Bok choy (pak choi) 1008 | 4546,See also SWEET POTATO Boniato 1009 | 4547,Broccoli Rabe (Italian Rapini)/ Chinese Broccoli (GAI LAN) Broccoli 1010 | 4548,Florettes Broccoli 1011 | 4549,Retailer Assigned Broccoli 1012 | 4550,Brussels sprouts 1013 | 4551,Retailer Assigned Brussels sprouts 1014 | 4552,Chinese/Napa/Wong Bok Cabbage 1015 | 4553,Taylors Gold Pears 1016 | 4554,Red Cabbage 1017 | 4555,"Savoy, Green Cabbage" 1018 | 4556,Retailer Assigned Cabbage 1019 | 4557,Retailer Assigned Cabbage 1020 | 4558,Cactus leaves (nopales/cactus pads) 1021 | 4559,Cardoon (cardoni) 1022 | 4560,Baby Carrots 1023 | 4561,French Carrots 1024 | 4562,Loose Carrots 1025 | 4563,Carrot Sticks Carrots 1026 | 4564,Retailer Assigned Carrots 1027 | 4565,Retailer Assigned Carrots 1028 | 4566,Florettes Cauliflower 1029 | 4567,Green Cauliflower 1030 | 4568,Purple Cauliflower 1031 | 4569,Retailer Assigned Cauliflower 1032 | 4570,Retailer Assigned Cauliflower 1033 | 4571,Retailer Assigned Cauliflower 1034 | 4572,Large Cauliflower 1035 | 4573,Baby Cauliflower 1036 | 4575,Hearts Celery 1037 | 4576,Celery Sticks Celery 1038 | 4577,Retailer Assigned Celery 1039 | 4578,Retailer Assigned Celery 1040 | 4579,Retailer Assigned Celery 1041 | 4580,Retailer Assigned Celery 1042 | 4581,Retailer Assigned Celery 1043 | 4582,Large Bunch Celery 1044 | 4583,Large Bunch Celery 1045 | 4584,Large Green Mango 1046 | 4585,Celery root/celeriac 1047 | 4586,Green Chard (swiss chard)/silverbeet 1048 | 4587,Red Chard (swiss chard)/silverbeet 1049 | 4588,Retailer Assigned Chard (swiss chard)/silverbeet 1050 | 4589,"Sweet Corn, Baby Corn" 1051 | 4590,"Sweet Corn, Bi-Color Corn" 1052 | 4591,Retailer Assigned Corn 1053 | 4592,Armenian Cucumber 1054 | 4593,English/Hot House/Long Seedless/Telegraph/Continental Cucumber 1055 | 4594,Japanese/White Cucumber 1056 | 4595,Lemon Cucumber 1057 | 4596,Pickling/Gherkin Cucumber 1058 | 4597,Retailer Assigned Cucumber 1059 | 4598,(See also RADISH) Daikon 1060 | 4599,Baby Eggplant (aubergine) 1061 | 4600,Baby White Eggplant (aubergine) 1062 | 4601,Japanese Eggplant (aubergine) 1063 | 4602,White Eggplant (aubergine) 1064 | 4603,Retailer Assigned Eggplant (aubergine) 1065 | 4604,Endive/chicory 1066 | 4605,Green Escarole/batavian chicory 1067 | 4606,Fiddlehead ferns 1068 | 4607,Gai (gui) choy (chinese or indian mustard) 1069 | 4608,Regular Garlic 1070 | 4609,Elephant Garlic 1071 | 4610,Retailer Assigned Garlic 1072 | 4611,Retailer Assigned Garlic 1073 | 4612,Regular Ginger root 1074 | 4613,Retailer Assigned Ginger root 1075 | 4614,Collard Greens 1076 | 4615,Dandelion Greens 1077 | 4616,Mustard Greens 1078 | 4617,Polk Greens Greens 1079 | 4618,Texas Mustard Greens 1080 | 4619,Turnip Greens 1081 | 4620,Retailer Assigned Greens 1082 | 4621,Retailer Assigned Greens 1083 | 4622,Retailer Assigned Greens 1084 | 4623,Retailer Assigned Greens 1085 | 4624,Retailer Assigned Greens 1086 | 4625,Horseradish root 1087 | 4626,Jicama/yam bean 1088 | 4627,Kale 1089 | 4628,Kohlrabi 1090 | 4629,Regular Leeks 1091 | 4630,Baby Leeks 1092 | 4631,Bibb/Flat/Round Lettuce 1093 | 4632,Boston/Butter Lettuce 1094 | 4633,Hydroponic Lettuce 1095 | 4634,Iceberg Lettuce 1096 | 4635,Red Seedless Grapes 1097 | 4636,Red Globe Grapes 1098 | 4637,Red Seeded Grapes 1099 | 4638,Fantasy/Marroo Grapes 1100 | 4639,Mache Lettuce 1101 | 4640,Romaine/Cos Lettuce 1102 | 4641,Retailer Assigned Lettuce 1103 | 4642,Retailer Assigned Lettuce 1104 | 4643,Retailer Assigned Lettuce 1105 | 4644,Malanga 1106 | 4645,"Small Regular, Button Mushrooms" 1107 | 4646,Black Forest Mushrooms 1108 | 4647,Chanterelle Mushrooms 1109 | 4648,Cremini/Brown/Swiss Brown Mushrooms 1110 | 4649,Oyster Mushrooms 1111 | 4650,Portabella Mushrooms 1112 | 4651,Shiitake Mushrooms 1113 | 4652,Wood Ear Mushrooms 1114 | 4653,Retailer Assigned Mushrooms 1115 | 4654,Retailer Assigned Mushrooms 1116 | 4655,Regular (Green) Okra 1117 | 4656,Chinese Okra 1118 | 4657,Red Okra 1119 | 4658,Boiling Onions 1120 | 4659,Bulb Onions 1121 | 4660,Pearl Onions 1122 | 4661,"Pickling, White Onions" 1123 | 4662,Shallots Onions 1124 | 4663,White Onions 1125 | 4664,Regular Tomatoes 1126 | 4665,Small Yellow/Brown Onions 1127 | 4666,Retailer Assigned Onions 1128 | 4667,Retailer Assigned Onions 1129 | 4668,Retailer Assigned Onions 1130 | 4669,Retailer Assigned Onions 1131 | 4670,Retailer Assigned Onions 1132 | 4671,Parsley root(hamburg parsley) 1133 | 4672,Parsnip 1134 | 4673,Blackeyed Peas 1135 | 4674,Green Peas 1136 | 4675,Sugar Snap Peas 1137 | 4676,Retailer Assigned Peas 1138 | 4677,Anaheim (Green and Red) Peppers (capsicums) 1139 | 4678,Banana (Yellow Long) Peppers (capsicums) 1140 | 4679,"Bell, Field Grown Peppers (capsicums)" 1141 | 4680,"Bell, Field Grown Peppers (capsicums)" 1142 | 4681,"Small Bell, Field Grown Peppers (capsicums)" 1143 | 4682,"Bell, Field Grown Peppers (capsicums)" 1144 | 4683,"Bell, Field Grown Peppers (capsicums)" 1145 | 4684,"Bell, Field Grown Peppers (capsicums)" 1146 | 4685,Chili Peppers (capsicums) 1147 | 4686,Chili Peppers (capsicums) 1148 | 4687,Cubanelle Peppers (capsicums) 1149 | 4688,"Bell, Greenhouse Peppers (capsicums)" 1150 | 4689,"Bell, Greenhouse Peppers (capsicums)" 1151 | 4690,Hot (Hungarian Hot) Peppers (capsicums) 1152 | 4691,Hot Mixed Peppers (capsicums) 1153 | 4692,Hungarian Wax Peppers (capsicums) 1154 | 4693,Jalapeno Peppers (capsicums) 1155 | 4694,Jalapeno Peppers (capsicums) 1156 | 4695,Japanese Peppers (capsicums) 1157 | 4696,Long Hot Peppers (capsicums) 1158 | 4697,Long Hot Peppers (capsicums) 1159 | 4698,Morita Chili Peppers (capsicums) 1160 | 4699,Negro Peppers (capsicums) 1161 | 4700,New Mexico Peppers (capsicums) 1162 | 4701,Pasilla Peppers (capsicums) 1163 | 4702,Pasilla Peppers (capsicums) 1164 | 4703,Pasilla Pod Peppers (capsicums) 1165 | 4704,Pinole Peppers (capsicums) 1166 | 4705,Poblano Peppers (capsicums) 1167 | 4706,Red Cheese Peppers (capsicums) 1168 | 4707,Red Finger Peppers (capsicums) 1169 | 4708,Red Pimiento/ Red Sweet Long Peppers (capsicums) 1170 | 4709,Serrano Peppers (capsicums) 1171 | 4710,Retailer Assigned Peppers (capsicums) 1172 | 4711,Retailer Assigned Peppers (capsicums) 1173 | 4712,Retailer Assigned Peppers (capsicums) 1174 | 4713,Retailer Assigned Peppers (capsicums) 1175 | 4714,Retailer Assigned Peppers (capsicums) 1176 | 4715,Retailer Assigned Peppers (capsicums) 1177 | 4716,Retailer Assigned Peppers (capsicums) 1178 | 4717,Retailer Assigned Peppers (capsicums) 1179 | 4718,Retailer Assigned Peppers (capsicums) 1180 | 4719,Retailer Assigned Peppers (capsicums) 1181 | 4720,Retailer Assigned Peppers (capsicums) 1182 | 4721,Retailer Assigned Peppers (capsicums) 1183 | 4722,Retailer Assigned Peppers (capsicums) 1184 | 4723,Creamer Potato 1185 | 4724,Creamer Potato 1186 | 4725,Russet Potato 1187 | 4726,Long Potato 1188 | 4727,Yellow Potato 1189 | 4728,Retailer Assigned Potato 1190 | 4729,Retailer Assigned Potato 1191 | 4730,Retailer Assigned Potato 1192 | 4731,Retailer Assigned Potato 1193 | 4732,Retailer Assigned Potato 1194 | 4733,Retailer Assigned Potato 1195 | 4734,Mini Pumpkin 1196 | 4735,Regular Pumpkin 1197 | 4736,Retailer Assigned Pumpkin 1198 | 4737,Retailer Assigned Pumpkin 1199 | 4738,Radicchio 1200 | 4739,Black Radish 1201 | 4740,Bunched White Radish 1202 | 4741,Italian Red Radish 1203 | 4742,Red Radish 1204 | 4743,White/Icicle Radish 1205 | 4744,Retailer Assigned Radish 1206 | 4745,Regular Rhubarb 1207 | 4746,Retailer Assigned Rhubarb 1208 | 4747,Regular Rutabagas (swede) 1209 | 4748,Retailer Assigned Rutabagas (swede) 1210 | 4749,Retailer Assigned Spinach 1211 | 4750,Acorn/Table Queen Squash 1212 | 4751,Acorn Squash 1213 | 4752,Acorn Squash 1214 | 4753,Australian Blue Squash 1215 | 4754,Baby Scallopini Squash 1216 | 4755,Baby Summer (Green) Squash 1217 | 4756,Baby Green Zucchini/Courgette Squash 1218 | 4757,Banana Squash 1219 | 4758,Buttercup Squash 1220 | 4759,Butternut Squash 1221 | 4760,Calabaza Squash 1222 | 4761,Chayote/Choko Squash 1223 | 4762,Extra Large Artichokes 1224 | 4763,Delicata/Sweet Potato Squash 1225 | 4764,(Sweet) Dumpling Squash 1226 | 4765,Gem Squash 1227 | 4766,Golden Delicious Squash 1228 | 4767,Golden Nugget Squash 1229 | 4768,Hubbard Squash 1230 | 4769,Kabocha Squash 1231 | 4770,Extra Large Hass Avocados 1232 | 4771,Medium Green Avocados 1233 | 4772,Chili Peppers (capsicums) 1234 | 4773,Patty Pan/Summer Squash 1235 | 4774,Red Kuri Squash 1236 | 4775,Scallopini Squash 1237 | 4776,Spaghetti/Vegetable Spaghetti Squash 1238 | 4777,Sunburst (Yellow) Squash 1239 | 4778,Regular Tomatoes 1240 | 4779,Sweet Mama Squash 1241 | 4780,Turban Squash 1242 | 4781,White Squash 1243 | 4782,Yellow Squash 1244 | 4783,"Foo Qua Bitter melon/bitter gourd, foo qua" 1245 | 4784,Yellow Squash 1246 | 4785,Retailer Assigned Squash 1247 | 4786,Retailer Assigned Squash 1248 | 4787,Retailer Assigned Squash 1249 | 4788,Retailer Assigned Squash 1250 | 4789,Retailer Assigned Squash 1251 | 4790,Sugar cane 1252 | 4791,Sunchokes (jerusalem artichokes) 1253 | 4792,Golden Tamarillo 1254 | 4793,Red Tamarillo 1255 | 4794,Small Taro root (dasheen) 1256 | 4795,Large Taro root (dasheen) 1257 | 4796,Cherry Tomatoes 1258 | 4797,Cherry Tomatoes 1259 | 4798,Small Greenhouse/Hydroponic/Regular Tomatoes 1260 | 4799,Large Greenhouse/Hydroponic/Regular Tomatoes 1261 | 4800,Native/Home Grown Tomatoes 1262 | 4801,Tomatillos/Husk Tomatoes Tomatoes 1263 | 4802,Dried Tomatoes 1264 | 4803,Teardrop/Pear Tomatoes 1265 | 4804,Teardrop/Pear Tomatoes 1266 | 4805,"Small Vine Ripe, Regular Tomatoes" 1267 | 4806,Retailer Assigned Tomatoes 1268 | 4807,Retailer Assigned Tomatoes 1269 | 4808,Retailer Assigned Tomatoes 1270 | 4809,Baby Turnip 1271 | 4810,Bunch/Banded Turnip 1272 | 4811,Purple Top Turnip 1273 | 4812,White Turnip 1274 | 4813,Retailer Assigned Turnip 1275 | 4814,Water chestnuts 1276 | 4815,Watercress 1277 | 4816,Golden Sweet potato/yam/kumara 1278 | 4817,Large Red/Orangy Red Flesh Sweet potato/yam/kumara 1279 | 4818,Retailer Assigned Name 1280 | 4819,Yuca root/cassava/manioc 1281 | 4820,Retailer Assigned Other vegetables 1282 | 4821,Retailer Assigned Other vegetables 1283 | 4822,Retailer Assigned Other vegetables 1284 | 4823,Retailer Assigned Other vegetables 1285 | 4824,Retailer Assigned Other vegetables 1286 | 4825,Retailer Assigned Other vegetables 1287 | 4826,Retailer Assigned Other vegetables 1288 | 4827,Retailer Assigned Other vegetables 1289 | 4828,Retailer Assigned Other vegetables 1290 | 4829,Retailer Assigned Other vegetables 1291 | 4830,Retailer Assigned Other vegetables 1292 | 4831,Retailer Assigned Other vegetables 1293 | 4832,Retailer Assigned Other vegetables 1294 | 4833,Retailer Assigned Other vegetables 1295 | 4834,Retailer Assigned Other vegetables 1296 | 4835,Retailer Assigned Other vegetables 1297 | 4836,Retailer Assigned Other vegetables 1298 | 4837,Retailer Assigned Other vegetables 1299 | 4838,Retailer Assigned Other vegetables 1300 | 4839,Retailer Assigned Other vegetables 1301 | 4840,Retailer Assigned Other vegetables 1302 | 4841,Retailer Assigned Other vegetables 1303 | 4842,Retailer Assigned Other vegetables 1304 | 4843,Retailer Assigned Other vegetables 1305 | 4844,Retailer Assigned Other vegetables 1306 | 4845,Retailer Assigned Other vegetables 1307 | 4846,Retailer Assigned Other vegetables 1308 | 4847,Retailer Assigned Other vegetables 1309 | 4848,Retailer Assigned Other vegetables 1310 | 4849,Retailer Assigned Other vegetables 1311 | 4850,Retailer Assigned Other vegetables 1312 | 4851,Retailer Assigned Other vegetables 1313 | 4852,Retailer Assigned Other vegetables 1314 | 4853,Retailer Assigned Other vegetables 1315 | 4854,Retailer Assigned Other vegetables 1316 | 4855,Retailer Assigned Other vegetables 1317 | 4856,Retailer Assigned Other vegetables 1318 | 4857,Retailer Assigned Other vegetables 1319 | 4858,Retailer Assigned Other vegetables 1320 | 4859,Retailer Assigned Other vegetables 1321 | 4860,(Dried Fruit) Apple slices 1322 | 4861,(Dried Fruit) Apricots 1323 | 4862,(Dried Fruit) Dates 1324 | 4863,Retailer Assigned Dates 1325 | 4864,(Dried Fruit) Pineapple 1326 | 4865,Regular Prunes 1327 | 4866,Pitted Prunes 1328 | 4867,Retailer Assigned Prunes 1329 | 4868,Black Raisins 1330 | 4869,Golden/Yellow Raisins 1331 | 4870,Retailer Assigned Other dried fruits 1332 | 4871,Retailer Assigned Other dried fruits 1333 | 4872,Retailer Assigned Other dried fruits 1334 | 4873,Retailer Assigned Other dried fruits 1335 | 4874,Retailer Assigned Other dried fruits 1336 | 4875,Retailer Assigned Other dried fruits 1337 | 4876,Retailer Assigned Other dried fruits 1338 | 4877,Retailer Assigned Other dried fruits 1339 | 4878,Retailer Assigned Other dried fruits 1340 | 4879,Retailer Assigned Other dried fruits 1341 | 4880,Retailer Assigned Other dried fruits 1342 | 4881,Retailer Assigned Other dried fruits 1343 | 4882,Retailer Assigned Other dried fruits 1344 | 4883,Retailer Assigned Other dried fruits 1345 | 4884,Arugula/rocket 1346 | 4885,Basil 1347 | 4886,Opal Basil 1348 | 4887,Sweet Basil 1349 | 4888,Chives 1350 | 4889,Cilantro (chinese parsley/coriander) 1351 | 4890,Chinese Yali Pears 1352 | 4891,Dill 1353 | 4892,Baby Dill 1354 | 4893,Pickling Dill 1355 | 4894,Lemongrass 1356 | 4895,Marjoram 1357 | 4896,Mint 1358 | 4897,Oregano 1359 | 4898,Oyster plant/salsify 1360 | 4899,Regular/Curly Parsley 1361 | 4901,Italian/Continental/French Parsley 1362 | 4902,Retailer Assigned Parsley 1363 | 4903,Rosemary 1364 | 4904,Sage 1365 | 4905,Sorrel 1366 | 4906,Tarragon 1367 | 4907,Thyme 1368 | 4908,Vanilla bean 1369 | 4909,Retailer Assigned Other herbs 1370 | 4910,Retailer Assigned Other herbs 1371 | 4911,Retailer Assigned Other herbs 1372 | 4912,Retailer Assigned Other herbs 1373 | 4913,Retailer Assigned Other herbs 1374 | 4914,Retailer Assigned Other herbs 1375 | 4915,Retailer Assigned Other herbs 1376 | 4916,Retailer Assigned Other herbs 1377 | 4917,Retailer Assigned Other herbs 1378 | 4918,Retailer Assigned Other herbs 1379 | 4919,Retailer Assigned Other herbs 1380 | 4920,Retailer Assigned Other herbs 1381 | 4921,Retailer Assigned Other herbs 1382 | 4922,Retailer Assigned Other herbs 1383 | 4923,Retailer Assigned Other herbs 1384 | 4924,Almonds 1385 | 4925,Retailer Assigned Almonds 1386 | 4926,Brazilnuts 1387 | 4927,Chestnuts 1388 | 4928,Cobnut/Hazelnut Filberts 1389 | 4929,Mixed nuts 1390 | 4930,Peanuts 1391 | 4931,Raw Peanuts 1392 | 4932,Roasted Peanuts 1393 | 4933,Roasted Peanuts 1394 | 4934,Retailer Assigned Peanuts 1395 | 4935,Retailer Assigned Peanuts 1396 | 4936,Pecans 1397 | 4937,Retailer Assigned Pecans 1398 | 4938,Pine nuts (pignoli) 1399 | 4939,Natural Pistachio 1400 | 4940,Red Pistachio 1401 | 4941,Retailer Assigned Pistachio 1402 | 4942,Sunflower seeds 1403 | 4943,Regular Walnuts 1404 | 4944,Black Walnuts 1405 | 4945,White Walnuts 1406 | 4946,Retailer Assigned Walnuts 1407 | 4947,Retailer Assigned Other nuts 1408 | 4948,Retailer Assigned Other nuts 1409 | 4949,Retailer Assigned Other nuts 1410 | 4950,Retailer Assigned Pears 1411 | 4951,Retailer Assigned Other nuts 1412 | 4952,Retailer Assigned Other nuts 1413 | 4953,Retailer Assigned Other nuts 1414 | 4954,Retailer Assigned Other nuts 1415 | 4955,Retailer Assigned Other nuts 1416 | 4956,Retailer Assigned Other nuts 1417 | 4957,Blue/Black Seeded Grapes 1418 | 4958,Medium Lemons 1419 | 4959,Large Red Mango 1420 | 4960,Fragrant Pears 1421 | 4961,Large Yellow Mango -------------------------------------------------------------------------------- /code/psteachingtools.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace PSTeachingTools { 3 | 4 | //enums used by the class 5 | public enum VegStatus { 6 | Raw, 7 | Boiled, 8 | Steamed, 9 | Sauteed, 10 | Fried, 11 | Baked, 12 | Roasted, 13 | Grilled 14 | } 15 | 16 | public enum VegColor { 17 | green, 18 | red, 19 | white, 20 | yellow, 21 | orange, 22 | purple, 23 | brown 24 | } 25 | public class PSVegetable { 26 | //properties 27 | public string Name {get; private set;} 28 | public int Count {get;set;} 29 | public int UPC {get; private set;} 30 | public VegStatus CookedState {get;set;} 31 | public bool IsRoot {get; private set;} 32 | public bool IsPeeled {get;set;} 33 | public VegColor Color {get; private set;} 34 | 35 | //methods 36 | public void Peel() { 37 | this.IsPeeled = bool.Parse("true"); 38 | } 39 | 40 | public void Prepare(VegStatus State) { 41 | this.CookedState = State; 42 | } 43 | 44 | //custom constructor 45 | public PSVegetable(string VegetableName,bool Root,VegColor VegetableColor,int UPCCode) { 46 | Name = VegetableName; 47 | IsRoot = Root; 48 | Color = VegetableColor; 49 | UPC = UPCCode; 50 | } 51 | 52 | } //class definition 53 | } //namespace 54 | -------------------------------------------------------------------------------- /code/rawveggies.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Count": 12, 4 | "Name": "Corn", 5 | "UPC": 4078, 6 | "CookingState": 6, 7 | "Root": false, 8 | "IsPeeled": false, 9 | "Color": 3 10 | }, 11 | { 12 | "Count": 4, 13 | "Name": "Tomato", 14 | "UPC": 4064, 15 | "CookingState": 0, 16 | "Root": false, 17 | "IsPeeled": false, 18 | "Color": 1 19 | }, 20 | { 21 | "Count": 11, 22 | "Name": "Cucumber", 23 | "UPC": 4062, 24 | "CookingState": 0, 25 | "Root": false, 26 | "IsPeeled": false, 27 | "Color": 0 28 | }, 29 | { 30 | "Count": 10, 31 | "Name": "Carrot", 32 | "UPC": 4562, 33 | "CookingState": 0, 34 | "Root": true, 35 | "IsPeeled": false, 36 | "Color": 4 37 | }, 38 | { 39 | "Count": 13, 40 | "Name": "Radish", 41 | "UPC": 4089, 42 | "CookingState": 0, 43 | "Root": true, 44 | "IsPeeled": false, 45 | "Color": 1 46 | }, 47 | { 48 | "Count": 14, 49 | "Name": "Peas", 50 | "UPC": 4674, 51 | "CookingState": 2, 52 | "Root": false, 53 | "IsPeeled": false, 54 | "Color": 0 55 | }, 56 | { 57 | "Count": 12, 58 | "Name": "Turnip", 59 | "UPC": 4811, 60 | "CookingState": 1, 61 | "Root": true, 62 | "IsPeeled": false, 63 | "Color": 5 64 | }, 65 | { 66 | "Count": 18, 67 | "Name": "Russet Potato", 68 | "UPC": 4725, 69 | "CookingState": 4, 70 | "Root": true, 71 | "IsPeeled": false, 72 | "Color": 6 73 | }, 74 | { 75 | "Count": 15, 76 | "Name": "Broccoli", 77 | "UPC": 4060, 78 | "CookingState": 2, 79 | "Root": false, 80 | "IsPeeled": false, 81 | "Color": 0 82 | }, 83 | { 84 | "Count": 7, 85 | "Name": "Zucchini", 86 | "UPC": 4067, 87 | "CookingState": 0, 88 | "Root": false, 89 | "IsPeeled": false, 90 | "Color": 0 91 | }, 92 | { 93 | "Count": 4, 94 | "Name": "Spinach", 95 | "UPC": 4090, 96 | "CookingState": 0, 97 | "Root": false, 98 | "IsPeeled": false, 99 | "Color": 0 100 | }, 101 | { 102 | "Count": 7, 103 | "Name": "Cauliflower", 104 | "UPC": 4572, 105 | "CookingState": 2, 106 | "Root": false, 107 | "IsPeeled": false, 108 | "Color": 2 109 | }, 110 | { 111 | "Count": 17, 112 | "Name": "Habanero Pepper", 113 | "UPC": 3125, 114 | "CookingState": 0, 115 | "Root": false, 116 | "IsPeeled": false, 117 | "Color": 4 118 | }, 119 | { 120 | "Count": 16, 121 | "Name": "Anaheim Pepper", 122 | "UPC": 4677, 123 | "CookingState": 0, 124 | "Root": false, 125 | "IsPeeled": false, 126 | "Color": 0 127 | }, 128 | { 129 | "Count": 19, 130 | "Name": "Red Bell Pepper", 131 | "UPC": 4088, 132 | "CookingState": 3, 133 | "Root": false, 134 | "IsPeeled": false, 135 | "Color": 1 136 | }, 137 | { 138 | "Count": 6, 139 | "Name": "Eggplant", 140 | "UPC": 4081, 141 | "CookingState": 4, 142 | "Root": false, 143 | "IsPeeled": false, 144 | "Color": 5 145 | }, 146 | { 147 | "Count": 2, 148 | "Name": "Endive", 149 | "UPC": 4604, 150 | "CookingState": 0, 151 | "Root": false, 152 | "IsPeeled": false, 153 | "Color": 0 154 | } 155 | ] -------------------------------------------------------------------------------- /code/vegetable-class.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | Param() 3 | #region class definitions 4 | 5 | #only add the class definition if it doesn't already exist in the current session 6 | Write-Verbose "Defining PSTeachingTools.PSVegetable class" 7 | Try { 8 | [void]([PSTeachingTools.PSVegetable].name) 9 | Write-Verbose "The class already exists in this session." 10 | } 11 | Catch { 12 | Write-Verbose "Adding class definition" 13 | Add-Type -path $PSScriptRoot\psteachingtools.cs 14 | } 15 | 16 | <# 17 | #this is the previous PowerShell class definition of the vegetable class 18 | 19 | #enumerations for a few of the class properties 20 | Enum Status { 21 | Raw 22 | Boiled 23 | Steamed 24 | Sauteed 25 | Fried 26 | Baked 27 | Roasted 28 | Grilled 29 | } 30 | 31 | Enum VegColor { 32 | green 33 | red 34 | white 35 | yellow 36 | orange 37 | purple 38 | brown 39 | } 40 | 41 | #a class to define a new type of object 42 | Class Vegetable { 43 | 44 | #properties 45 | [String]$Name 46 | [Int]$Count = (Get-Random -minimum 1 -maximum 20) 47 | [Int]$UPC 48 | [Status]$CookedState 49 | [boolean]$IsRoot 50 | [boolean]$IsPeeled 51 | [VegColor]$Color 52 | 53 | #methods 54 | [void]Peel() { 55 | $this.IsPeeled = $True 56 | } 57 | 58 | [void]Prepare([status]$State) { 59 | $this.CookedState = $State 60 | } 61 | 62 | #constructors 63 | Vegetable ([String]$Name, [boolean]$IsRoot, [vegcolor]$Color, [Int]$UPC) { 64 | $this.name = $Name 65 | $this.IsRoot = $IsRoot 66 | $this.Color = $Color 67 | $this.upc = $UPC 68 | } 69 | 70 | #an empty constructor 71 | Vegetable () { } 72 | } 73 | 74 | #endregion 75 | #> 76 | -------------------------------------------------------------------------------- /docs/Get-Vegetable.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSTeachingTools-help.xml 3 | Module Name: PSTeachingTools 4 | online version: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/docs/Get-Vegetable.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-Vegetable 9 | 10 | ## SYNOPSIS 11 | 12 | Get vegetable objects 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | Get-Vegetable [[-Name] ] [-RootOnly] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Use this command to retrieve vegetable objects from the local computer. The default is to retrieve all objects but you can select them by name or filter for only root vegetables like carrots. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-Vegetable 30 | 31 | UPC Count Name State Color 32 | --- ----- ---- ----- ----- 33 | 4078 12 Corn Roasted yellow 34 | 4064 4 Tomato Raw red 35 | 4062 11 Cucumber Raw green 36 | 4562 10 Carrot Raw orange 37 | 4089 13 Radish Raw red 38 | 4674 14 Peas Steamed green 39 | 4811 12 Turnip Boiled purple 40 | 4725 18 Russet Potato Fried brown 41 | 4060 15 Broccoli Steamed green 42 | 4067 7 Zucchini Raw green 43 | 4090 4 Spinach Raw green 44 | 4572 7 Cauliflower Steamed white 45 | 3125 17 Habanero Pepper Raw orange 46 | 4677 16 Anaheim Pepper Raw green 47 | 4088 19 Red Bell Pepper Sauteed red 48 | 4081 6 Eggplant Fried purple 49 | 4604 2 Endive Raw green 50 | 51 | ``` 52 | 53 | ### Example 2 54 | 55 | ```powershell 56 | PS C:\> Get-Vegetable Eggplant 57 | 58 | UPC Count Name State Color 59 | --- ----- ---- ----- ----- 60 | 4081 6 Eggplant Fried purple 61 | 62 | ``` 63 | 64 | Get a vegetable object by name. 65 | 66 | ### Example 3 67 | 68 | ```powershell 69 | PS C:\> Get-Vegetable -RootOnly 70 | 71 | UPC Count Name State Color 72 | --- ----- ---- ----- ----- 73 | 4562 10 Carrot Raw orange 74 | 4089 13 Radish Raw red 75 | 4811 12 Turnip Boiled purple 76 | 4725 18 Russet Potato Fried brown 77 | ``` 78 | 79 | Get only root vegetables. 80 | 81 | ### Example 4 82 | 83 | ```powershell 84 | PS C:\> Get-Vegetable | Group CookedState 85 | 86 | Count Name Group 87 | ----- ---- ----- 88 | 9 Raw {PSTeachingTools.PSVegetable, PSTeachingToo... 89 | 1 Boiled {PSTeachingTools.PSVegetable} 90 | 3 Steamed {PSTeachingTools.PSVegetable, PSTeachingToo... 91 | 1 Sauteed {PSTeachingTools.PSVegetable} 92 | 2 Fried {PSTeachingTools.PSVegetable, PSTeachingToo... 93 | 1 Roasted {PSTeachingTools.PSVegetable} 94 | ``` 95 | 96 | Group vegetables by their CookedState property. Note that the default output is not necessarily the actual property name. You can only see that by using Get-Member. 97 | 98 | ### Example 5 99 | 100 | ```powershell 101 | PS C:\> Get-Vegetable | Get-Member 102 | 103 | TypeName: PSTeachingTools.PSVegetable 104 | 105 | Name MemberType Definition 106 | ---- ---------- ---------- 107 | State AliasProperty State = CookedState 108 | Equals Method bool Equals(System.Object obj) 109 | GetHashCode Method int GetHashCode() 110 | GetType Method type GetType() 111 | Peel Method void Peel() 112 | Prepare Method void Prepare(PSTeachingTools.VegStatus State) 113 | ToString Method string ToString() 114 | Color Property PSTeachingTools.VegColor Color {get;} 115 | CookedState Property PSTeachingTools.VegStatus CookedState {get;set;} 116 | Count Property int Count {get;set;} 117 | IsPeeled Property bool IsPeeled {get;set;} 118 | IsRoot Property bool IsRoot {get;} 119 | Name Property string Name {get;} 120 | UPC Property int UPC {get;} 121 | ``` 122 | 123 | Discover the properties and methods of a vegetable object. 124 | 125 | ## PARAMETERS 126 | 127 | ### -Name 128 | 129 | The name of a vegetable. 130 | 131 | ```yaml 132 | Type: String 133 | Parameter Sets: (All) 134 | Aliases: 135 | 136 | Required: False 137 | Position: 0 138 | Default value: None 139 | Accept pipeline input: True (ByPropertyName, ByValue) 140 | Accept wildcard characters: True 141 | ``` 142 | 143 | ### -RootOnly 144 | 145 | Only get root vegetables like carrots or turnips. 146 | 147 | ```yaml 148 | Type: SwitchParameter 149 | Parameter Sets: (All) 150 | Aliases: 151 | 152 | Required: False 153 | Position: Named 154 | Default value: None 155 | Accept pipeline input: False 156 | Accept wildcard characters: False 157 | ``` 158 | 159 | ### CommonParameters 160 | 161 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 162 | 163 | ## INPUTS 164 | 165 | ### String 166 | 167 | ## OUTPUTS 168 | 169 | ### PSTeachingTools.PSVegetable 170 | 171 | ## NOTES 172 | 173 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 174 | 175 | ## RELATED LINKS 176 | 177 | [Set-Vegetable](Set-Vegetable.md) 178 | 179 | [New-Vegetable](New-Vegetable.md) 180 | 181 | [Remove-Vegetable](Remove-Vegetable.md) 182 | -------------------------------------------------------------------------------- /docs/New-Vegetable.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSTeachingTools-help.xml 3 | Module Name: PSTeachingTools 4 | online version: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/docs/New-Vegetable.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-Vegetable 9 | 10 | ## SYNOPSIS 11 | 12 | Create a new vegetable object. 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | New-Vegetable [-Name] [-Color] [-Count ] [-Root] -UPC [-Passthru] [-WhatIf] [-Confirm] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Use this command to create a new vegetable object. You must specify a vegetable name, UPC value, and color. Note that this command does not write anything to the pipeline unless you use -Passthru. 23 | 24 | You can search the module variable $vegetableplu to find a matching item. See examples. 25 | 26 | ## EXAMPLES 27 | 28 | ### Example 1 29 | 30 | ```powershell 31 | PS C:\> $vegetableplu | where name -match kiwi 32 | 33 | PLUCode Name 34 | ------- ---- 35 | 3279 Golden Kiwifruit 36 | 3280 Jumbo Regular Kiwifruit 37 | 4030 Regular Kiwifruit 38 | 4301 Retailer Assigned Kiwifruit 39 | 40 | PS C:\> New-Vegetable -name kiwi -color green -upc 4030 -passthru 41 | 42 | UPC Count Name State Color 43 | --- ----- ---- ----- ----- 44 | 4030 1 kiwi Raw green 45 | ``` 46 | 47 | Find a UPC value from $vegetableplu and create a new vegetable object. 48 | 49 | ### Example 2 50 | 51 | ```powershell 52 | PS C:\> New-Vegetable -name kale -color green -upc 4627 -passthru | Set-Vegetable -cookingstate sauteed -passthru 53 | 54 | UPC Count Name State Color 55 | --- ----- ---- ----- ----- 56 | 4627 1 kale Sauteed green 57 | ``` 58 | 59 | ### Example 3 60 | 61 | ```powershell 62 | PS C:\> New-Vegetable -name "Sweet Potato" -upc 3334 -color orange -root 63 | ``` 64 | 65 | ## PARAMETERS 66 | 67 | ### -Color 68 | 69 | What is the color of the vegetable? This is a value from the [PSTeachingTools.VegColor] enumeration. 70 | 71 | ```yaml 72 | Type: VegColor 73 | Parameter Sets: (All) 74 | Aliases: 75 | Accepted values: green, red, white, yellow, orange, purple, brown 76 | 77 | Required: True 78 | Position: 1 79 | Default value: None 80 | Accept pipeline input: True (ByPropertyName) 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -Count 85 | 86 | How many vegetables do you want? Pick a number between 1 and 20. 87 | 88 | ```yaml 89 | Type: Int32 90 | Parameter Sets: (All) 91 | Aliases: 92 | 93 | Required: False 94 | Position: Named 95 | Default value: None 96 | Accept pipeline input: True (ByPropertyName) 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### -Name 101 | 102 | What is the name of the vegetable? 103 | 104 | ```yaml 105 | Type: String 106 | Parameter Sets: (All) 107 | Aliases: 108 | 109 | Required: True 110 | Position: 0 111 | Default value: None 112 | Accept pipeline input: True (ByPropertyName) 113 | Accept wildcard characters: False 114 | ``` 115 | 116 | ### -Passthru 117 | 118 | Write the object to the pipeline. 119 | 120 | ```yaml 121 | Type: SwitchParameter 122 | Parameter Sets: (All) 123 | Aliases: 124 | 125 | Required: False 126 | Position: Named 127 | Default value: None 128 | Accept pipeline input: False 129 | Accept wildcard characters: False 130 | ``` 131 | 132 | ### -Root 133 | 134 | Indicate that this is a root vegetable. 135 | 136 | ```yaml 137 | Type: SwitchParameter 138 | Parameter Sets: (All) 139 | Aliases: IsRoot 140 | 141 | Required: False 142 | Position: Named 143 | Default value: None 144 | Accept pipeline input: True (ByPropertyName) 145 | Accept wildcard characters: False 146 | ``` 147 | 148 | ### -Confirm 149 | 150 | Prompts you for confirmation before running the cmdlet. 151 | 152 | ```yaml 153 | Type: SwitchParameter 154 | Parameter Sets: (All) 155 | Aliases: cf 156 | 157 | Required: False 158 | Position: Named 159 | Default value: None 160 | Accept pipeline input: False 161 | Accept wildcard characters: False 162 | ``` 163 | 164 | ### -UPC 165 | 166 | Enter a valid PLU code. You can search $VegetablePLU for a valid code. 167 | 168 | ```yaml 169 | Type: Int32 170 | Parameter Sets: (All) 171 | Aliases: 172 | 173 | Required: True 174 | Position: Named 175 | Default value: None 176 | Accept pipeline input: True (ByPropertyName) 177 | Accept wildcard characters: False 178 | ``` 179 | 180 | ### -WhatIf 181 | 182 | Shows what would happen if the cmdlet runs. The cmdlet is not run. 183 | 184 | ```yaml 185 | Type: SwitchParameter 186 | Parameter Sets: (All) 187 | Aliases: wi 188 | 189 | Required: False 190 | Position: Named 191 | Default value: None 192 | Accept pipeline input: False 193 | Accept wildcard characters: False 194 | ``` 195 | 196 | ### CommonParameters 197 | 198 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 199 | 200 | ## INPUTS 201 | 202 | ### None 203 | 204 | ## OUTPUTS 205 | 206 | ### None 207 | 208 | ### PSTeachingTools.PSVegetable 209 | 210 | ## NOTES 211 | 212 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 213 | 214 | ## RELATED LINKS 215 | 216 | [Get-Vegetable](Get-Vegetable.md) 217 | 218 | [Set-Vegetable](Set-Vegetable.md) 219 | 220 | [Remove-Vegetable](Remove-Vegetable.md) 221 | -------------------------------------------------------------------------------- /docs/Remove-Vegetable.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSTeachingTools-help.xml 3 | Module Name: PSTeachingTools 4 | online version: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/docs/Remove-Vegetable.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Remove-Vegetable 9 | 10 | ## SYNOPSIS 11 | 12 | Delete a Vegetable object. 13 | 14 | ## SYNTAX 15 | 16 | ### input 17 | 18 | ```yaml 19 | Remove-Vegetable [[-InputObject] ] [-Passthru] [-WhatIf] [-Confirm] [] 20 | ``` 21 | 22 | ### name 23 | 24 | ```yaml 25 | Remove-Vegetable [[-Name] ] [-Passthru] [-WhatIf] [-Confirm] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | This command will remove a vegetable object from your PowerShell session. It will not write anything to the pipeline unless you use -Passthru. 31 | 32 | ## EXAMPLES 33 | 34 | ### Example 1 35 | 36 | ```powershell 37 | PS C:\> Remove-Vegetable -name corn 38 | ``` 39 | 40 | ### Example 2 41 | 42 | ```powershell 43 | PS C:\> Get-Vegetable *pepper | Remove-Vegetable -passthru 44 | 45 | UPC Count Name State Color 46 | --- ----- ---- ----- ----- 47 | 3125 17 habanero pepper Raw orange 48 | 4677 16 Anaheim pepper Raw green 49 | 4088 19 red bell pepper Sauteed red 50 | ``` 51 | 52 | ## PARAMETERS 53 | 54 | ### -Confirm 55 | 56 | Prompts you for confirmation before running the cmdlet. 57 | 58 | ```yaml 59 | Type: SwitchParameter 60 | Parameter Sets: (All) 61 | Aliases: cf 62 | 63 | Required: False 64 | Position: Named 65 | Default value: None 66 | Accept pipeline input: False 67 | Accept wildcard characters: False 68 | ``` 69 | 70 | ### -InputObject 71 | 72 | A piped in Vegetable object. 73 | 74 | ```yaml 75 | Type: PSVegetable[] 76 | Parameter Sets: input 77 | Aliases: 78 | 79 | Required: False 80 | Position: 0 81 | Default value: None 82 | Accept pipeline input: True (ByValue) 83 | Accept wildcard characters: False 84 | ``` 85 | 86 | ### -Name 87 | 88 | The name of a vegetable object. 89 | 90 | ```yaml 91 | Type: String 92 | Parameter Sets: name 93 | Aliases: 94 | 95 | Required: False 96 | Position: 0 97 | Default value: None 98 | Accept pipeline input: True (ByPropertyName, ByValue) 99 | Accept wildcard characters: True 100 | ``` 101 | 102 | ### -Passthru 103 | 104 | Write the removed object to the pipeline 105 | 106 | ```yaml 107 | Type: SwitchParameter 108 | Parameter Sets: (All) 109 | Aliases: 110 | 111 | Required: False 112 | Position: Named 113 | Default value: None 114 | Accept pipeline input: False 115 | Accept wildcard characters: False 116 | ``` 117 | 118 | ### -WhatIf 119 | 120 | Shows what would happen if the cmdlet runs. 121 | The cmdlet is not run. 122 | 123 | ```yaml 124 | Type: SwitchParameter 125 | Parameter Sets: (All) 126 | Aliases: wi 127 | 128 | Required: False 129 | Position: Named 130 | Default value: None 131 | Accept pipeline input: False 132 | Accept wildcard characters: False 133 | ``` 134 | 135 | ### CommonParameters 136 | 137 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 138 | 139 | ## INPUTS 140 | 141 | ### PSTeachingTools.PSVegetable[] 142 | 143 | ### System.String 144 | 145 | ## OUTPUTS 146 | 147 | ### none 148 | 149 | ### PSTeachingTools.PSVegetable 150 | 151 | ## NOTES 152 | 153 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 154 | 155 | ## RELATED LINKS 156 | 157 | [Get-Vegetable](Get-Vegetable.md) 158 | 159 | [Set-Vegetable](Set-Vegetable.md) 160 | 161 | [New-Vegetable](New-Vegetable.md) 162 | -------------------------------------------------------------------------------- /docs/Set-Vegetable.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSTeachingTools-help.xml 3 | Module Name: PSTeachingTools 4 | online version: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/docs/Set-Vegetable.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Set-Vegetable 9 | 10 | ## SYNOPSIS 11 | 12 | Set a vegetable property 13 | 14 | ## SYNTAX 15 | 16 | ### input (Default) 17 | 18 | ```yaml 19 | Set-Vegetable [[-InputObject] ] [-Count ] 20 | [-CookingState ] [-Passthru] [-WhatIf] [-Confirm] [] 21 | ``` 22 | 23 | ### name 24 | 25 | ```yaml 26 | Set-Vegetable [[-Name] ] [-Count ] [-CookingState ] [-Passthru] [-WhatIf] [-Confirm] [] 27 | ``` 28 | 29 | ## DESCRIPTION 30 | 31 | Use this command to set vegetable properties. You can either specify a vegetable by name or pipe objects from Get-Vegetable. By default this command does not write anything to the pipeline unless you use -Passthru. 32 | 33 | ## EXAMPLES 34 | 35 | ### Example 1 36 | 37 | ```powershell 38 | PS C:\> Set-Vegetable eggplant -cookingstate Roasted -count 5 -passthru 39 | 40 | UPC Count Name State Color 41 | --- ----- ---- ----- ----- 42 | 4081 5 eggplant Roasted purple 43 | ``` 44 | 45 | ### Example 2 46 | 47 | ```powershell 48 | PS C:\> Get-Vegetable -Name "anaheim pepper" | Set-Vegetable -CookingState grilled 49 | ``` 50 | 51 | ## PARAMETERS 52 | 53 | ### -Confirm 54 | 55 | ```yaml 56 | Type: SwitchParameter 57 | Parameter Sets: (All) 58 | Aliases: cf 59 | 60 | Required: False 61 | Position: Named 62 | Default value: None 63 | Accept pipeline input: False 64 | Accept wildcard characters: False 65 | ``` 66 | 67 | ### -CookingState 68 | 69 | Set the vegetable's cooking state. This is a value from the [PSTeachingTools.VegStatus] enumeration. 70 | 71 | ```yaml 72 | Type: VegStatus 73 | Parameter Sets: (All) 74 | Aliases: state 75 | Accepted values: Raw, Boiled, Steamed, Sauteed, Fried, Baked, Roasted, Grilled 76 | 77 | Required: False 78 | Position: Named 79 | Default value: None 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -Count 85 | 86 | Set the number of each vegetable. This should be a number between 1 and 20. 87 | 88 | ```yaml 89 | Type: Int32 90 | Parameter Sets: (All) 91 | Aliases: 92 | 93 | Required: False 94 | Position: Named 95 | Default value: None 96 | Accept pipeline input: False 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### -InputObject 101 | 102 | A piped in vegetable object. 103 | 104 | ```yaml 105 | Type: PSVegetable[] 106 | Parameter Sets: input 107 | Aliases: 108 | 109 | Required: False 110 | Position: 0 111 | Default value: None 112 | Accept pipeline input: True (ByValue) 113 | Accept wildcard characters: False 114 | ``` 115 | 116 | ### -Name 117 | 118 | The name of a vegetable. 119 | 120 | ```yaml 121 | Type: String 122 | Parameter Sets: name 123 | Aliases: 124 | 125 | Required: False 126 | Position: 0 127 | Default value: None 128 | Accept pipeline input: True (ByValue) 129 | Accept wildcard characters: False 130 | ``` 131 | 132 | ### -Passthru 133 | 134 | Write the object to the pipeline. 135 | 136 | ```yaml 137 | Type: SwitchParameter 138 | Parameter Sets: (All) 139 | Aliases: 140 | 141 | Required: False 142 | Position: Named 143 | Default value: None 144 | Accept pipeline input: False 145 | Accept wildcard characters: False 146 | ``` 147 | 148 | ### -WhatIf 149 | 150 | ```yaml 151 | Type: SwitchParameter 152 | Parameter Sets: (All) 153 | Aliases: wi 154 | 155 | Required: False 156 | Position: Named 157 | Default value: None 158 | Accept pipeline input: False 159 | Accept wildcard characters: False 160 | ``` 161 | 162 | ### CommonParameters 163 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 164 | 165 | ## INPUTS 166 | 167 | ### String 168 | 169 | ### PSTeachingTools.PSVegetable 170 | 171 | ## OUTPUTS 172 | 173 | ### None 174 | 175 | ### PSTeachingTools.PSVegetable 176 | 177 | ## NOTES 178 | 179 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 180 | 181 | ## RELATED LINKS 182 | 183 | [Get-Vegetable](Get-Vegetable.md) 184 | 185 | [New-Vegetable](New-Vegetable.md) 186 | 187 | [Remove-Vegetable](Remove-Vegetable.md) 188 | -------------------------------------------------------------------------------- /docs/Start-TypedDemo.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSTeachingTools-help.xml 3 | Module Name: PSTeachingTools 4 | online version: https://github.com/jdhitsolutions/PSTeachingTools/blob/master/docs/Start-TypedDemo.md 5 | schema: 2.0.0 6 | --- 7 | 8 | # Start-TypedDemo 9 | 10 | ## SYNOPSIS 11 | 12 | Simulate a PowerShell console session 13 | 14 | ## SYNTAX 15 | 16 | ### Random (Default) 17 | 18 | ```yaml 19 | Start-TypedDemo [-File] [-RandomMinimum ] [-RandomMaximum ] [-Transcript ] [-NoExecute] [-NewSession] [] 20 | ``` 21 | 22 | ### Static 23 | 24 | ```yaml 25 | Start-TypedDemo [-File] [-Pause ] [-NoExecute] [-NewSession] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | This command simulates an interactive PowerShell session. It will process a text file of PowerShell commands. The function will insert your prompt and "type" out each command when you press any key. At the end of the typed command or whenever a pipe character is inserted, the script will pause. Press Enter or any key to continue. If it is the end of the command pressing Enter will execute the command. Use the -NoExecute parameter to run through the demo without executing any commands. 31 | 32 | Commented lines in your demo file will be skipped. 33 | 34 | Press 'q' or ESC at any pause to quit the demo. 35 | 36 | This command will NOT run properly in the PowerShell ISE. It is designed to be used in a PowerShell console session. It appears to work fine in a Windows Terminal PowerShell session. 37 | 38 | VARIABLE NAMES 39 | Do not use any variables in your script file that are also used in this script. These are the variables you most likely need to avoid: 40 | 41 | $file 42 | $i 43 | $running 44 | $key 45 | $command 46 | $count 47 | 48 | MULTI-LINE COMMANDS 49 | To use a multi-line command, in your demo file, put a :: before the first line and :: after the last line: 50 | 51 | ... 52 | Get-Date 53 | :: 54 | get-ciminstance win32_logicaldisk -filter "Drivetype=3" | 55 | Select Caption,VolumeName,Size,Freespace | 56 | format-table -autosize 57 | :: 58 | Get-Process 59 | ... 60 | 61 | The function will simulate a nested prompt. Press any key after the last >> to execute. Avoid using the line continuation character in your demo file. 62 | 63 | TIMING 64 | By default the function will insert a random pause interval between characters. This is a random value in milliseconds between the -RandomMinimum and -RandomMaximum parameters which have default values of 50 and 140 respectively. If you want a static or consistent interval, then use the -Pause parameter. The recommended value is 80. 65 | 66 | SCOPE 67 | All the commands in your demo script are executed in the context of the Start-TypedDemo function. This means you have to be very aware of scope. While you can access items in the global scope like PSDrives, anything you create in the demo script will not persist. 68 | 69 | However, command history will be persisted to the history and command buffers as well as the PSReadLine history file. This allows you to use the Up Arrow or the history commands to find items you ran in the demo. 70 | 71 | COMMENTS 72 | Any line that begins with # will be treated as a comment and skipped. If you have a multi-line comment you will need to put a # at the beginning of each line. You can't use PowerShell's block comment characters. 73 | 74 | LIVE COMMANDS 75 | Starting in v4.1.0, you can insert into your demo file. When Start-TypedDemo reaches this line, it will let you enter a live command. Enter a command carefully and without error. Backspaces will break this step. Due to timing, the first key stroke may not be detected. This feature should be considered *experimental*. 76 | 77 | ## EXAMPLES 78 | 79 | ### Example 1 80 | 81 | ```powershell 82 | PS C:\> Start-TypedDemo c:\work\demo.txt 83 | ``` 84 | 85 | Run the commands in c:\work\demo.txt using the random defaults 86 | 87 | ### Example 2 88 | 89 | ```powershell 90 | PS C:\> Start-TypedDemo c:\work\demo.txt -pause 100 -NoExecute 91 | ``` 92 | 93 | Run the commands in c:\work\demo.txt using a static interval of 100 milliseconds. The function will only type the commands. They will not be executed. 94 | 95 | ### Example 3 96 | 97 | ```powershell 98 | PS C:\> Start-TypedDemo c:\work\demo.txt -transcript c:\work\demotrans.txt 99 | ``` 100 | 101 | Run the commands in c:\work\demo.txt using the random defaults and create a transcript file. 102 | 103 | ## PARAMETERS 104 | 105 | ### -File 106 | 107 | The file name of PowerShell commands to execute. It can have any extension you choose. 108 | 109 | ```yaml 110 | Type: String 111 | Parameter Sets: (All) 112 | Aliases: 113 | 114 | Required: True 115 | Position: 1 116 | Default value: None 117 | Accept pipeline input: False 118 | Accept wildcard characters: False 119 | ``` 120 | 121 | ### -Pause 122 | 123 | The typing speed interval between characters in milliseconds. The recommended value is 100. 124 | 125 | ```yaml 126 | Type: Int32 127 | Parameter Sets: Static 128 | Aliases: 129 | 130 | Required: False 131 | Position: Named 132 | Default value: 80 133 | Accept pipeline input: False 134 | Accept wildcard characters: False 135 | ``` 136 | 137 | ### -RandomMinimum 138 | 139 | The minimum time interval between characters in milliseconds. The default is 50. 140 | 141 | ```yaml 142 | Type: Int32 143 | Parameter Sets: Random 144 | Aliases: 145 | 146 | Required: False 147 | Position: Named 148 | Default value: 50 149 | Accept pipeline input: False 150 | Accept wildcard characters: False 151 | ``` 152 | 153 | ### -RandomMaximum 154 | 155 | The maximum time interval between characters in milliseconds. The default is 140. 156 | 157 | ```yaml 158 | Type: Int32 159 | Parameter Sets: Random 160 | Aliases: 161 | 162 | Required: False 163 | Position: Named 164 | Default value: 140 165 | Accept pipeline input: False 166 | Accept wildcard characters: False 167 | ``` 168 | 169 | ### -Transcript 170 | 171 | The file name and path for a transcript session file. Existing files will be overwritten. The transcript will have a minimum header. 172 | 173 | ```yaml 174 | Type: String 175 | Parameter Sets: Random 176 | Aliases: 177 | 178 | Required: False 179 | Position: Named 180 | Default value: None 181 | Accept pipeline input: False 182 | Accept wildcard characters: False 183 | ``` 184 | 185 | ### -NoExecute 186 | 187 | Do not execute any of the commands. 188 | 189 | ```yaml 190 | Type: SwitchParameter 191 | Parameter Sets: (All) 192 | Aliases: 193 | 194 | Required: False 195 | Position: Named 196 | Default value: False 197 | Accept pipeline input: False 198 | Accept wildcard characters: False 199 | ``` 200 | 201 | ### -NewSession 202 | 203 | Simulate a new PowerShell session with the copyright header and a prompt. This works best if you start your demo from the C: drive. The header will be mocked depending on the version of PowerShell you are running. This will only work with Windows PowerShell 5.1 and PowerShell 7. 204 | 205 | ```yaml 206 | Type: SwitchParameter 207 | Parameter Sets: (All) 208 | Aliases: 209 | 210 | Required: False 211 | Position: Named 212 | Default value: False 213 | Accept pipeline input: False 214 | Accept wildcard characters: False 215 | ``` 216 | 217 | ### CommonParameters 218 | 219 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 220 | 221 | ## INPUTS 222 | 223 | ### None 224 | 225 | ## OUTPUTS 226 | 227 | ### None. This only writes to the host console, not the pipeline. Although you can create a transcript. 228 | 229 | ## NOTES 230 | 231 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 232 | 233 | ## RELATED LINKS 234 | -------------------------------------------------------------------------------- /docs/about_PSTeachingTools.md: -------------------------------------------------------------------------------- 1 | # PSTeachingTools 2 | 3 | ## about_PSTeachingTools 4 | 5 | # SHORT DESCRIPTION 6 | 7 | The PSTeachingTools module is designed to offer a set of PowerShell commands 8 | that can be used to demonstrate and teach PowerShell fundamentals. 9 | 10 | # LONG DESCRIPTION 11 | 12 | Very often, PowerShell teachers use out-of-the-box cmdlets like Get-Process and 13 | Get-Service to demonstrate concepts and techniques. However, sometimes the 14 | commands themselves or their output might be distracting. This module contains 15 | a set of commands based on a more neutral and non-technical noun, a vegetable. 16 | 17 | The *-Vegetable commands are designed to be combined in pipelined expressions 18 | like regular PowerShell commands. These demonstration commands also write 19 | objects to the pipeline. The custom objects have a corresponding 20 | custom format.ps1xml file, which displays results in a formatted table. Many 21 | PowerShell commands, like Get-Service use this same technique. The concept 22 | behind these demonstration commands is that once students see how vegetable 23 | objects can be used, consumed and manipulated in PowerShell, the same concepts 24 | and techniques can be applied to service, process, or any other object type 25 | in PowerShell. 26 | 27 | For advanced classes, you can use the module files themselves to teach concepts 28 | as module development, advanced functions, PowerShell classes, working with 29 | JSON and CSV files, and format.ps1xml files. 30 | 31 | # EXAMPLES 32 | 33 | The Get-Vegetable command is designed to demonstrate how PowerShell works and 34 | how you can work with PowerShell. Once the student understands how this command 35 | works, they should be able to apply the concepts to any other command. 36 | 37 | ```powershell 38 | PS C:\> Get-Vegetable 39 | 40 | UPC Count Name State Color 41 | --- ----- ---- ----- ----- 42 | 4078 12 corn Roasted yellow 43 | 4064 4 tomato Raw red 44 | 4062 11 cucumber Raw green 45 | 4562 10 carrot Raw orange 46 | 4089 13 radish Raw red 47 | 4674 14 peas Steamed green 48 | 4811 12 turnip Boiled purple 49 | 4725 18 russet potato Fried brown 50 | 4060 15 broccoli Steamed green 51 | 4067 7 zucchini Raw green 52 | 4090 4 spinach Raw green 53 | 4572 7 cauliflower Steamed white 54 | 3125 17 habanero pepper Raw orange 55 | 4677 16 Anaheim pepper Raw green 56 | 4088 19 red bell pepper Sauteed red 57 | 4081 6 eggplant Fried purple 58 | 4604 2 endive Raw green 59 | 60 | PS C:\> Get-Vegetable corn | Get-Member 61 | 62 | TypeName: PSTeachingTools.PSVegetable 63 | 64 | Name MemberType Definition 65 | ---- ---------- ---------- 66 | State AliasProperty State = CookedState 67 | Equals Method bool Equals(System.Object obj) 68 | GetHashCode Method int GetHashCode() 69 | GetType Method type GetType() 70 | Peel Method void Peel() 71 | Prepare Method void Prepare(PSTeachingTools.VegStatus State) 72 | ToString Method string ToString() 73 | Color Property PSTeachingTools.VegColor Color {get;} 74 | CookedState Property PSTeachingTools.VegStatus CookedState {get;set;} 75 | Count Property int Count {get;set;} 76 | IsPeeled Property bool IsPeeled {get;set;} 77 | IsRoot Property bool IsRoot {get;} 78 | Name Property string Name {get;} 79 | UPC Property int UPC {get;} 80 | ``` 81 | 82 | The default display uses the format.ps1xml file which does NOT reflect the 83 | complete object. This is typical PowerShell behavior. Get-Process and Process 84 | objects are a good example. 85 | 86 | Here are some other ways you could use the command to demonstrate common 87 | PowerShell techniques and concepts: 88 | 89 | ```powershell 90 | PS C:\> Get-Vegetable | Group-Object -Property Color 91 | 92 | Count Name Group 93 | ----- ---- ----- 94 | 8 green {PSTeachingTools.PSVegetable, PSTeachingToo... 95 | 3 red {PSTeachingTools.PSVegetable, PSTeachingToo... 96 | 1 white {PSTeachingTools.PSVegetable} 97 | 1 yellow {PSTeachingTools.PSVegetable} 98 | 2 orange {PSTeachingTools.PSVegetable, PSTeachingToo... 99 | 2 purple {PSTeachingTools.PSVegetable, PSTeachingToo... 100 | 1 brown {PSTeachingTools.PSVegetable} 101 | 102 | PS C:\> Get-Vegetable -RootOnly | Measure-Object -Property count -sum 103 | 104 | Count : 4 105 | Average : 106 | Sum : 53 107 | Maximum : 108 | Minimum : 109 | StandardDeviation : 110 | Property : Count 111 | ``` 112 | 113 | Read full help and examples for New-Vegetable and Set-Vegetable. 114 | 115 | ## PSVegetable Class 116 | 117 | The object class and its enumerations are now exposed in PowerShell. 118 | 119 | ```powershell 120 | PS C:\> [enum]::GetNames([PSTeachingTools.VegColor]) 121 | green 122 | red 123 | white 124 | yellow 125 | orange 126 | purple 127 | brown 128 | 129 | PS C:\> [enum]::GetNames([PSTeachingTools.VegStatus]) 130 | Raw 131 | Boiled 132 | Steamed 133 | Sauteed 134 | Fried 135 | Baked 136 | Roasted 137 | Grilled 138 | 139 | PS C:\> [PSTeachingTools.PSVegetable]::new.OverloadDefinitions 140 | PSTeachingTools.PSVegetable new(string VegetableName, bool Root, PSTeachingTools.VegColor VegetableColor, int UPCCode) 141 | ``` 142 | 143 | The PSVegetable object has a custom format file with defined table views. 144 | 145 | ```powershell 146 | PS C:\> Get-FormatView PSTeachingTools.PSVegetable 147 | 148 | Type: PSTeachingTools.PSVegetable 149 | 150 | Format Name 151 | ------ ---- 152 | Table default 153 | Table State 154 | Table color 155 | ``` 156 | 157 | # SEE ALSO 158 | 159 | https://aka.ms/powershell 160 | 161 | https://jdhitsolutions.com/blog/essential-powershell-resources/ 162 | 163 | https://jdhitsolutions.com/blog/powershell-tips-tricks-and-advice/ 164 | 165 | # KEYWORDS 166 | 167 | - teaching 168 | - demo 169 | -------------------------------------------------------------------------------- /en-us/about_PSTeachingTools.help.txt: -------------------------------------------------------------------------------- 1 | TOPIC 2 | about_PSTeachingTools 3 | 4 | SHORT DESCRIPTION 5 | The PSTeachingTools module is designed to offer a set of PowerShell commands 6 | that can be used to demonstrate and teach PowerShell fundamentals. 7 | 8 | LONG DESCRIPTION 9 | Very often, PowerShell teachers use out-of-the-box cmdlets like Get-Process 10 | and Get-Service to demonstrate concepts and techniques. However, sometimes 11 | the commands themselves or their output might be distracting. This module 12 | contains a set of commands based on a more neutral and non-technical noun, 13 | a vegetable. 14 | 15 | The *-Vegetable commands are designed to be combined in pipelined 16 | expressions like regular PowerShell commands. These demonstration commands 17 | also write objects to the pipeline. The custom objects have a corresponding 18 | custom format.ps1xml file, which displays results in a formatted table. Many 19 | PowerShell commands, like Get-Service use this same technique. The concept 20 | behind these demonstration commands is that once students see how vegetable 21 | objects can be used, consumed and manipulated in PowerShell, the same 22 | concepts and techniques can be applied to service, process, or any other 23 | object type in PowerShell. 24 | 25 | For advanced classes, you can use the module files themselves to teach 26 | concepts as module development, advanced functions, PowerShell classes, 27 | working with JSON and CSV files, and format.ps1xml files. 28 | 29 | EXAMPLES 30 | The Get-Vegetable command is designed to demonstrate how PowerShell works 31 | and how you can work with PowerShell. Once the student understands how this 32 | command works, they should be able to apply the concepts to any other 33 | command. 34 | 35 | PS C:\> Get-Vegetable 36 | 37 | UPC Count Name State Color 38 | --- ----- ---- ----- ----- 39 | 4078 12 corn Roasted yellow 40 | 4064 4 tomato Raw red 41 | 4062 11 cucumber Raw green 42 | 4562 10 carrot Raw orange 43 | 4089 13 radish Raw red 44 | 4674 14 peas Steamed green 45 | 4811 12 turnip Boiled purple 46 | 4725 18 russet potato Fried brown 47 | 4060 15 broccoli Steamed green 48 | 4067 7 zucchini Raw green 49 | 4090 4 spinach Raw green 50 | 4572 7 cauliflower Steamed white 51 | 3125 17 habanero pepper Raw orange 52 | 4677 16 Anaheim pepper Raw green 53 | 4088 19 red bell pepper Sauteed red 54 | 4081 6 eggplant Fried purple 55 | 4604 2 endive Raw green 56 | 57 | PS C:\> Get-Vegetable corn | Get-Member 58 | 59 | TypeName: PSTeachingTools.PSVegetable 60 | 61 | Name MemberType Definition 62 | ---- ---------- ---------- 63 | State AliasProperty State = CookedState 64 | Equals Method bool Equals(System.Object obj) 65 | GetHashCode Method int GetHashCode() 66 | GetType Method type GetType() 67 | Peel Method void Peel() 68 | Prepare Method void Prepare(PSTeachingTools.VegStatus State) 69 | ToString Method string ToString() 70 | Color Property PSTeachingTools.VegColor Color {get;} 71 | CookedState Property PSTeachingTools.VegStatus CookedState {get;set;} 72 | Count Property int Count {get;set;} 73 | IsPeeled Property bool IsPeeled {get;set;} 74 | IsRoot Property bool IsRoot {get;} 75 | Name Property string Name {get;} 76 | UPC Property int UPC {get;} 77 | 78 | The default display uses the format.ps1xml file which does NOT reflect the 79 | complete object. This is typical PowerShell behavior. Get-Process and 80 | Process objects are a good example. 81 | 82 | Here are some other ways you could use the command to demonstrate common 83 | PowerShell techniques and concepts: 84 | 85 | PS C:\> Get-Vegetable | Group-Object -Property Color 86 | 87 | Count Name Group 88 | ----- ---- ----- 89 | 8 green {PSTeachingTools.PSVegetable, PSTeachingToo... 90 | 3 red {PSTeachingTools.PSVegetable, PSTeachingToo... 91 | 1 white {PSTeachingTools.PSVegetable} 92 | 1 yellow {PSTeachingTools.PSVegetable} 93 | 2 orange {PSTeachingTools.PSVegetable, PSTeachingToo... 94 | 2 purple {PSTeachingTools.PSVegetable, PSTeachingToo... 95 | 1 brown {PSTeachingTools.PSVegetable} 96 | 97 | PS C:\> Get-Vegetable -RootOnly | Measure-Object -Property count -sum 98 | 99 | Count : 4 100 | Average : 101 | Sum : 53 102 | Maximum : 103 | Minimum : 104 | StandardDeviation : 105 | Property : Count 106 | 107 | Read full help and examples for New-Vegetable and Set-Vegetable. 108 | 109 | PSVegetable Class 110 | The object class and its enumerations are now exposed in PowerShell. 111 | 112 | PS C:\> [enum]::GetNames([PSTeachingTools.VegColor]) 113 | green 114 | red 115 | white 116 | yellow 117 | orange 118 | purple 119 | brown 120 | 121 | PS C:\> [enum]::GetNames([PSTeachingTools.VegStatus]) 122 | Raw 123 | Boiled 124 | Steamed 125 | Sauteed 126 | Fried 127 | Baked 128 | Roasted 129 | Grilled 130 | 131 | PS C:\> [PSTeachingTools.PSVegetable]::new.OverloadDefinitions 132 | PSTeachingTools.PSVegetable new(string VegetableName, bool Root, PSTeachingTools.VegColor VegetableColor, int UPCCode) 133 | 134 | The PSVegetable object has a custom format file with defined table views. 135 | 136 | PS C:\> Get-FormatView PSTeachingTools.PSVegetable 137 | 138 | Type: PSTeachingTools.PSVegetable 139 | 140 | Format Name 141 | ------ ---- 142 | Table default 143 | Table State 144 | Table color 145 | 146 | SEE ALSO 147 | https://aka.ms/powershell 148 | https://jdhitsolutions.com/blog/essential-powershell-resources/ 149 | https://jdhitsolutions.com/blog/powershell-tips-tricks-and-advice/ 150 | 151 | KEYWORDS 152 | - teaching 153 | - demo 154 | -------------------------------------------------------------------------------- /formats/vegetable.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSTeachingTools.PSVegetable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 5 15 | left 16 | 17 | 18 | 19 | 7 20 | right 21 | 22 | 23 | 24 | 20 25 | left 26 | 27 | 28 | 29 | 8 30 | left 31 | 32 | 33 | 34 | 10 35 | left 36 | 37 | 38 | 39 | 40 | 41 | 42 | UPC 43 | 44 | 45 | Count 46 | 47 | 48 | Name 49 | 50 | 51 | CookedState 52 | 53 | 54 | Color 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | State 64 | 65 | PSTeachingTools.PSVegetable 66 | 67 | 68 | CookedState 69 | 70 | 71 | 72 | 73 | 74 | 75 | 20 76 | left 77 | 78 | 79 | 80 | 8 81 | left 82 | 83 | 84 | 85 | 8 86 | right 87 | 88 | 89 | 90 | 91 | 92 | 96 | 97 | Name 98 | 99 | 100 | Color 101 | 102 | 103 | Count 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | color 113 | 114 | PSTeachingTools.PSVegetable 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 15 123 | left 124 | 125 | 126 | 127 | 8 128 | left 129 | 130 | 131 | 132 | 10 133 | left 134 | 135 | 136 | 137 | 138 | 139 | 143 | 144 | "$($AnsiVegColor[$($_.color.ToString())])$($_.Name)$([char]27)[0m" 145 | 146 | 147 | Count 148 | 149 | 150 | State 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /samples/sampledemo.txt: -------------------------------------------------------------------------------- 1 | #this is a sample demo file for Start-TypedDemo 2 | #The command will pause at every | character 3 | 4 | $psversiontable 5 | 6 | pushd 7 | cd C:\ 8 | get-date 9 | get-process | where-object {$_.WS -ge 10MB} 10 | 11 | #this is how you would define a multi-line command 12 | :: 13 | get-process | 14 | where-object {$_.WS -ge 10MB} | 15 | Select-Object Name,Handles,ID,WS 16 | :: 17 | clear-host 18 | get-psdrive 19 | popd -------------------------------------------------------------------------------- /samples/sampledemo2.txt: -------------------------------------------------------------------------------- 1 | #this example uses live commands 2 | 3 | Get-Date 4 | $psversiontable.psversion 5 | #use to indicate you want to enter a single command 6 | #type slowly and carefully. Backspaces will break this command 7 | #Live commands are an experimental feature 8 | 9 | 10 | get-ciminstance win32_bios 11 | cls 12 | 13 | -------------------------------------------------------------------------------- /tests/PSTeachingTools.tests.ps1: -------------------------------------------------------------------------------- 1 | 2 | Describe PSTeachingTools { 3 | It "Is under development" { 4 | $true | Should Be $true 5 | } 6 | } 7 | --------------------------------------------------------------------------------