├── BuildJsonFile.ps1 ├── Changelog.md ├── LICENSE ├── PSChristmas.psd1 ├── PSChristmas.psm1 ├── README.md ├── Tests └── PSChristmas.Tests.ps1 ├── assets ├── pschristmas.png └── show-pschristmas.jpg ├── data.json ├── docs ├── Get-PSChristmasPresent.md ├── Invoke-Jingle.md ├── New-ElfName.md ├── New-PSChristmas.md ├── New-PSChristmasGreeting.md ├── Show-PSChristmasMessage.md └── Write-Festive.md ├── en-us └── PSChristmas-help.xml ├── formats └── pschristmas.format.ps1xml └── functions ├── Get-PSChristmasPresent.ps1 ├── Invoke-Jingle.ps1 ├── New-ElfName.ps1 ├── New-PSChristmas.ps1 ├── New-PSChristmasGreeting.ps1 ├── Show-PSChristmasMessage.ps1 ├── Write-Festive.ps1 └── helpers.ps1 /BuildJsonFile.ps1: -------------------------------------------------------------------------------- 1 | $texts = @("Merry Christmas", "Happy Holidays", "HO-HO-HO", "Vrolijk Kerstfeest", "Joyeux No?l", "Frohe Weihnachten", "Hyv?? Joulua", "Gl?delig Jul", "Kala Christouyenna", "Mele Kalikimaka", "Buon Natale", "Merry Xmas", "Merry Christmas & A Happy New Year", "Meri Kuri", "God Jul", "Nollaig Chridheil", "Feliz Navidad", "Sch?ni Wiehnachte", "Mutlu Noeller", "Nadolig Llawen", "toDwI'ma' qoS yItIvqu'", "??????????? ?????????", "Priec?gus Ziemassv?tkus", "Vesel Bo?i?", "Vesel? Vianoce", "Vesel? V?noce", "Feliz Natal", "???? ????????????", "Boldog Kar?csonyt", "Let it snow, let it snow, let it snow", "Have a holly,jolly Christmas", "Peace" 2 | ) 3 | 4 | $first = @("Toby", "Bernard", "Princess", "Harvey", "Chuck", "Doris", "Elsa", "Snookums", "Honey", "Norm", "Coco", "Sven", "Inga", "Boris", "Benedict", "Sunshine", "Kiki", "Nutmeg", "Humperdink", "Jack", "Bertha", "Matilda", "Clarice", "Dwight", "Hermey", "Rupert", "Lady", "Izzy", "Timmy", "Jason", "Tammy", "Enoch", "Suzie", "Esmerelda", "Doc", "Matilda", "Kevin", "Bob", "Sleepy", "Dopey", "Snazzy", "Paula", "Izzy", "Wizzy", "Tizzy", "Todd", "Zippy", "Moonlight", "Luna", "Hermione", "Pepper", "Pip", "Pop", "Gilligan", "Captain", "Kip", "Diogones", "Archimedes", "Fred", "Sneezy", "Prof.","Dr.","Queen","Abner","Dot","Starlight","Misty","Dusty") 5 | 6 | $mod = @("Ginger", "Glitter", "Frosty", "Sugar", "Sour", "Pepper", "Minty", "Crazy", "Spicy", "Pickle", "Twinkle", "Sparkle", "Disco", "Red", "Green", "Little", "Big", "Tiny", "Glow", "Shimmer", "Dazzle", "Winter", "Jingle", "Puffy", "Fluffy", "Saucy", "Crinkle", "Sticky", "Purple", "Dizzy", "Crumple", "Jumble", "Stinky", "Stuffy", "Smelly", "Drizzle", "Fizzle", "Spotted", "Zany", "Zippy", "Pumpkin", "Doozy", "Woozy", "Scuzzy", "Furry", "Dusty", "Yellow", "Pink") 7 | 8 | $last = @{"pants", "toes", "bottom", "beard", "nose", "puss", "lips", "ears", "socks", "stockings", "belly", "cheeks", "bells", "chin", "mctush", "sticks", "fish", "whisker", "boots", "slippers", "knicker", "knocker", "muffin", "puff", "heels", "knees", "toe", "knickerknocker", "fluff", "fingers", "eyes", "buckle", "butt", "lobes", "knuckles","wind","end","gas","top","nuts"} 9 | 10 | $presents = @("Socks", "Barbie", "Elmo", "XBox", "GI Joe", "Underwear", "Hot Wheels", "EZ Bake Oven", "Walkman", "PS4", "Pajamas", "Stratego", "Ginzu Knives", "Chia Pet", "Tie", "Mittens", "Bicycle", "Pony", "Battleship", "Cabbage Patch Doll", "Slippers", "Sled", "Bourbon", "Coloring book", "Risk", "Clue", "Mystery Date", "Rock'em Sock'em Robots", "rocks", "Tesla", "puppy", "kitten", "baby goat", "VCR", "Parcheesi", "Transformers", "Bedazzler", "painting set", "iPad", "xBox", "Wii", "Scotch", "iPhone", "Jarts","Creepy Crawlers","Connect Four","Vodka") 11 | 12 | [PSCustomObject]@{ 13 | Greeting = $texts 14 | FirstNames = $first 15 | Modifiers = $mod 16 | LastNames = $last 17 | Presents = $presents 18 | 19 | } | ConvertTo-Json | Set-Content -Path .\data.json -Encoding Unicode 20 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | # ChangeLog for PSChristmas 2 | 3 | ## [Unreleased] 4 | 5 | ## [2.2.0] - 2024-12-02 6 | 7 | ### Added 8 | 9 | - Added a custom form file for PSChristmas objects 10 | - Added new items to the data json file 11 | 12 | ### Changed 13 | 14 | - Converted Changelog format 15 | - License update 16 | - Code cleanup and module reorganization 17 | - Updated Pester tests to version 5.x 18 | - Updated `README` 19 | 20 | ### Fixed 21 | 22 | - Fixed duplicate gifts 23 | 24 | ## [v2.1.0] - 2019-12-24 25 | 26 | - Updated `Show-PSChristmas` to not require a PSChristmas object 27 | - Updated `New-ElfName` to generate up to 50 names 28 | - Help updates 29 | - Updated `README.md` 30 | 31 | ## [v2.0.0] - 2019-12-06 32 | 33 | - fixed alias export bug 34 | - code restructuring and cleanup 35 | - Added `Write-Festive` command 36 | - Added error handling in case `$XmasData` is missing 37 | - Changed nouns from MyChristmas to PSChristmas 38 | - Changed class from myChristmas to PSChristmas 39 | - Added new items to data file 40 | 41 | ## [v1.2.0] - 2018-12-04 42 | 43 | - exported xmasData variable (Issue #5) 44 | - minor code cleanup 45 | - minor updates to module manifest 46 | - updates to json data 47 | - moved alias definitions to functions 48 | - modified private function that displays graphic to not clear the host 49 | - updated README 50 | - updated help 51 | 52 | ## [v1.1.0] - 2017-12-11 53 | 54 | - updated json data file (Issue #2) 55 | - removed duplicate present in json data file (Issue #3) 56 | - Modified build json file to encode file as Unicode (Issue #4) 57 | - Modified parameter validation for `Get-MyChristmasPresent` (Issue #1) 58 | 59 | ## v1.0.0 - 2017-12-09 60 | 61 | - renamed some of the functions for uniqueness and consistency 62 | - updated for official release 63 | - added documentation 64 | 65 | ## v0.0.6 - 2016-12-21 66 | 67 | - Updated Pester tests 68 | - Modified module to dot source functions using $PSScriptRoot 69 | - updated manifest 70 | 71 | ## v0.0.5 - 2016-12-20 72 | 73 | - Added Pester tests 74 | 75 | ## v0.0.4 - 2016-12-20 76 | 77 | - Added new property to show day of the week for Christmas 78 | - Added new functions to show graphics and play tune 79 | - revised README 80 | - updated manifest 81 | 82 | ## v0.0.3 - 2016-12-20 83 | 84 | - added functions to create Christmas object 85 | - moved text lists to a json file 86 | - Updated manifest 87 | 88 | ## v0.0.2 - 2016-12-20 89 | 90 | - added module manifest 91 | 92 | ## v0.0.1 - 2016-12-20 93 | 94 | - Initial build 95 | 96 | 97 | [Unreleased]: https://github.com/jdhitsolutions/PSChristmas/compare/v2.2.0..HEAD 98 | [2.2.0]: https://github.com/jdhitsolutions/PSChristmas/compare/vv2.1.0..v2.2.0 99 | [v2.1.0]: https://github.com/jdhitsolutions/PSChristmas/compare/v2.0.0..v2.1.0 100 | [v2.0.0]: https://github.com/jdhitsolutions/PSChristmas/compare/v1.2.0..v2.0.0 101 | [v1.2.0]: https://github.com/jdhitsolutions/PSChristmas/compare/v1.1.0..v1.2.0 102 | [v1.1.0]: https://github.com/jdhitsolutions/PSChristmas/compare/v1.0.0..v1.1.0 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2024 JDH Information Technology Solutions, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PSChristmas.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for PSChristmas 3 | # 4 | 5 | @{ 6 | RootModule = 'PSChristmas.psm1' 7 | ModuleVersion = '2.2.0' 8 | GUID = '234a068f-005b-4253-a833-48a25b8b4157' 9 | Author = 'Jeff Hicks' 10 | CompatiblePSEditions = 'Desktop', 'Core' 11 | CompanyName = 'JDH Information Technology Solutions, Inc.' 12 | Copyright = '2016-2024 JDH Information Technology Solutions, Inc.' 13 | Description = 'a demonstration class-based PowerShell module with a number of Christmas related commands.' 14 | PowerShellVersion = '5.1' 15 | FunctionsToExport = @('New-ElfName', 'Get-PSChristmasPresent', 'New-PSChristmasGreeting', 16 | 'New-PSChristmas', 'Show-PSChristmasMessage', 'Invoke-Jingle', 'Write-Festive') 17 | VariablesToExport = 'xmasData' 18 | AliasesToExport = 'jingle', 'elfme', 'wf' 19 | FormatsToProcess = @('formats/PSChristmas.format.ps1xml') 20 | PrivateData = @{ 21 | PSData = @{ 22 | Tags = 'demonstration', 'christmas', 'powershell-class' 23 | LicenseUri = 'https://github.com/jdhitsolutions/PSChristmas/blob/master/LICENSE' 24 | ProjectUri = 'https://github.com/jdhitsolutions/PSChristmas' 25 | ReleaseNotes = @' 26 | ## [2.2.0] - 2024-12-02 27 | 28 | ### Added 29 | 30 | - Added a custom form file for PSChristmas objects 31 | - Added new items to the data json file 32 | 33 | ### Changed 34 | 35 | - Converted Changelog format 36 | - License update 37 | - Code cleanup and module reorganization 38 | - Updated Pester tests to version 5.x 39 | - Updated `README` 40 | 41 | ### Fixed 42 | 43 | - Fixed duplicate gifts 44 | '@ 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /PSChristmas.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | A demo PowerShell class-based module 3 | #> 4 | 5 | #dot source helper functions 6 | Get-ChildItem -Path $PSScriptRoot\functions\*.ps1 | ForEach-Object { 7 | . $_.FullName 8 | } 9 | 10 | #region Class 11 | 12 | Enum ListStatus { 13 | Naughty 14 | Nice 15 | } 16 | 17 | Class PSChristmas { 18 | #class properties 19 | [string]$Greeting 20 | [string]$ElfName 21 | [ListStatus]$List 22 | [string]$ChristmasDay 23 | [int32]$DaysRemaining 24 | [string]$CountDown 25 | 26 | #class methods 27 | [void]Refresh() { 28 | Write-Verbose '[CLASS] Invoking Refresh()' 29 | #calculate christmas for the current year that should be culture aware 30 | $Christmas = [datetime]::new( (Get-Date).Year, 12, 25) 31 | 32 | Write-Verbose "[CLASS] Christmas this year is $Christmas" 33 | $this.ChristmasDay = $Christmas.DayOfWeek 34 | $span = $Christmas - (Get-Date) 35 | $this.DaysRemaining = $span.totalDays 36 | #strip off milliseconds 37 | $TimeString = $span.ToString() 38 | $this.CountDown = $TimeString.Substring(0, $TimeString.LastIndexOf('.')) 39 | 40 | Write-Verbose '[CLASS] Getting new greeting' 41 | $this.Greeting = New-PSChristmasGreeting 42 | } 43 | 44 | [void]Play() { 45 | Write-Verbose '[CLASS] Invoking Play()' 46 | PlayTune 47 | } 48 | 49 | [void]Show() { 50 | Write-Verbose '[CLASS] Invoking Show()' 51 | ShowGraphic 52 | } 53 | 54 | #class constructor 55 | PSChristmas() { 56 | Write-Verbose '[CLASS] Invoking Constructor' 57 | $this.ElfName = New-ElfName 58 | 59 | if ( (Get-Date).Second % 2) { 60 | $this.List = [ListStatus]::Naughty 61 | } 62 | else { 63 | $this.List = [ListStatus]::Nice 64 | } 65 | 66 | #set the rest of the properties by invoking the defined 67 | #Refresh() method 68 | 69 | $this.Refresh() 70 | } 71 | 72 | } #close class definition 73 | #endregion 74 | 75 | #import data from json 76 | $xmasData = Get-Content $PSScriptRoot\data.json | ConvertFrom-Json 77 | Export-ModuleMember -Variable xmasData -Alias 'elfme', 'jingle', 'wf' 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSChristmas 2 | 3 | [![PSGallery Version](https://img.shields.io/powershellgallery/v/PSChristmas.png?style=for-the-badge&logo=powershell&label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSChristmas/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSChristmas.png?style=for-the-badge&label=Downloads)](https://www.powershellgallery.com/packages/PSChristmas/) 4 | 5 | This project is a demonstration class based PowerShell module. The root module contains a simple enumeration and a class definition. Most of the class methods have been moved to an external set of helper functions. 6 | 7 | You can install a release from GitHub or the PowerShell Gallery. 8 | 9 | ```powershell 10 | Install-Module PSChristmas 11 | ``` 12 | 13 | Almost all of the functions will also work in PowerShell 7 cross-platform. 14 | 15 | ## Using the Class :christmas_tree: 16 | 17 | In order for the user of the module to not have to understand how to work with objects and classes, the module contains a function to create a new instance of the class called `New-PSChristmas`. 18 | 19 | ```powershell 20 | $xmas = New-PSChristmas 21 | ``` 22 | 23 | The object has a custom format files. 24 | 25 | ![PSChristmas](./assets/pschristmas.png) 26 | 27 | Or you can look at the full object. 28 | 29 | ```powershell 30 | PS C:\> $xmas | Select-Object * 31 | 32 | Greeting : Vesel Božič 33 | ElfName : Snookums Pinkpuff 34 | List : Nice 35 | ChristmasDay : Wednesday 36 | DaysRemaining : 22 37 | CountDown : 22.06:06:09 38 | ``` 39 | 40 | If you examine the object with `Get-Member` you will see a few methods. 41 | 42 | ```powershell 43 | PS C:\> $xmas | Get-Member 44 | 45 | TypeName: PSChristmas 46 | 47 | Name MemberType Definition 48 | ---- ---------- ---------- 49 | Equals Method bool Equals(System.Object obj) 50 | GetHashCode Method int GetHashCode() 51 | GetType Method type GetType() 52 | Play Method void Play() 53 | Refresh Method void Refresh() 54 | Show Method void Show() 55 | ToString Method string ToString() 56 | CountDown Property string CountDown {get;set;} 57 | Day Property string Day {get;set;} 58 | DaysRemaining Property int DaysRemaining {get;set;} 59 | ElfName Property string ElfName {get;set;} 60 | Greeting Property string Greeting {get;set;} 61 | List Property ListStatus List {get;set;} 62 | ``` 63 | 64 | However, the user can use the module functions to invoke these methods. The functions are designed to invoke the method from the class. 65 | 66 | ```powershell 67 | $xmas | Invoke-Jingle 68 | $xmas | Show-PSChristmasMessage 69 | ``` 70 | 71 | ## Helper Functions :elf: 72 | 73 | The module includes several other functions, some of which are exported for the user to manually run. 74 | 75 | ```powershell 76 | PS C:\> Get-Command -Module PSChristmas 77 | 78 | CommandType Name Version Source 79 | ----------- ---- ------- ------ 80 | Function Get-PSChristmasPresent 2.2.0 PSChristmas 81 | Function Invoke-Jingle 2.2.0 PSChristmas 82 | Function New-ElfName 2.2.0 PSChristmas 83 | Function New-PSChristmas 2.2.0 PSChristmas 84 | Function New-PSChristmasGreeting 2.2.0 PSChristmas 85 | Function Show-PSChristmasMessage 2.2.0 PSChristmas 86 | Function Write-Festive 2.2.0 PSChristmas 87 | ``` 88 | 89 | One benefit of having external functions is that they are easier to test with something like Pester or update without having to modify the class definition. 90 | 91 | ## Data 92 | 93 | Some of the functions rely on text lists and randomization. Those lists have been moved to a json file. The json file is imported in the module and turned into an object. 94 | 95 | The json file is encoded with Unicode to support different language characters. Be careful opening the file where the encoding my change. 96 | 97 | ```powershell 98 | $xmasData = Get-Content .\data.json | ConvertFrom-Json 99 | ``` 100 | 101 | The data can then be used in a function like this: 102 | 103 | ```powershell 104 | $presents = $xmasData.presents | Get-Random -count $Count 105 | ``` 106 | 107 | One benefit of using the json file as opposed to an enumeration is that the latter doesn't like spaces in the values. But using a format like json allows entries like "coloring book". In addition, if you wanted to add more entries, you only have to modify the json file and not any of the code. 108 | 109 | If you look at the module folder you'll also see a script called `BuildJsonFile.ps1` which will create the json file for you based on settings within the file. 110 | 111 | The variable, `xmasData` is exported to your PowerShell session so you can work with it. 112 | 113 | ### Note 114 | 115 | Previous versions of this module used a noun and class name of *myChristmas*. I kept thinking about these commands as *PSChristmas* so I changed the references. This is a silly educational module so I'm not expecting I broke anyone's holiday production scripts. 116 | 117 | ### Credits 118 | 119 | The functions to display the holiday graphics and play the tune are things I've collected since the earliest days of PowerShell. I wish I could remember who created all of them. I seem to recall "repurposing" at least from Lee Holmes, Hal Rottenberg and MoW. 120 | 121 | ![Show-PSChristmas](./assets/show-pschristmas.jpg) 122 | 123 | The [class](http://bit.ly/2gTxigI) and [module]("http://bit.ly/2gYjXUc) are also described on my [blog](https://jdhitsolutions.com/blog) 124 | -------------------------------------------------------------------------------- /Tests/PSChristmas.Tests.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSChristmas/d37c8454e5d0e0829500f4c74af4aefb186f5dcb/Tests/PSChristmas.Tests.ps1 -------------------------------------------------------------------------------- /assets/pschristmas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSChristmas/d37c8454e5d0e0829500f4c74af4aefb186f5dcb/assets/pschristmas.png -------------------------------------------------------------------------------- /assets/show-pschristmas.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSChristmas/d37c8454e5d0e0829500f4c74af4aefb186f5dcb/assets/show-pschristmas.jpg -------------------------------------------------------------------------------- /data.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdhitsolutions/PSChristmas/d37c8454e5d0e0829500f4c74af4aefb186f5dcb/data.json -------------------------------------------------------------------------------- /docs/Get-PSChristmasPresent.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PSChristmasPresent 9 | 10 | ## SYNOPSIS 11 | 12 | Get a Christmas present 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | Get-PSChristmasPresent [[-Count] ] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Run this command to get one or more presents from Santa. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Get-PSChristmasPresent 30 | Barbie 31 | ``` 32 | 33 | ### Example 2 34 | 35 | ```powershell 36 | PS C:\> Get-PSChristmasPresent 4 37 | Slippers 38 | EZ Bake Oven 39 | Bicycle 40 | Walkman 41 | ``` 42 | 43 | ## PARAMETERS 44 | 45 | ### -Count 46 | 47 | The number of presents to get. 48 | 49 | ```yaml 50 | Type: Int32 51 | Parameter Sets: (All) 52 | Aliases: 53 | 54 | Required: False 55 | Position: 0 56 | Default value: 1 57 | Accept pipeline input: False 58 | Accept wildcard characters: False 59 | ``` 60 | 61 | ## INPUTS 62 | 63 | ### None 64 | 65 | ## OUTPUTS 66 | 67 | ### System.String 68 | 69 | ## NOTES 70 | 71 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 72 | 73 | ## RELATED LINKS 74 | -------------------------------------------------------------------------------- /docs/Invoke-Jingle.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Invoke-Jingle 9 | 10 | ## SYNOPSIS 11 | 12 | Play a Christmas tune 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | Invoke-Jingle [-Christmas] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | The command name explains it all. You can pipe a myChristmas object to this function, otherwise it will create one on the fly. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\>Invoke-Jingle 30 | Nollaig Chridheil, Diogones Furrylobes 31 | 32 | ``` 33 | 34 | There is no pipeline output. A message is written to the console using Write-Host. 35 | 36 | ## PARAMETERS 37 | 38 | ### -Christmas 39 | 40 | An object created with New-PSChristmas 41 | 42 | ```yaml 43 | Type: myChristmas 44 | Parameter Sets: (All) 45 | Aliases: 46 | 47 | Required: True 48 | Position: 0 49 | Default value: None 50 | Accept pipeline input: True (ByValue) 51 | Accept wildcard characters: False 52 | ``` 53 | 54 | ## INPUTS 55 | 56 | ### myChristmas 57 | 58 | ## OUTPUTS 59 | 60 | ### None 61 | 62 | ## NOTES 63 | 64 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 65 | 66 | ## RELATED LINKS 67 | 68 | [New-PSChristmas]() 69 | -------------------------------------------------------------------------------- /docs/New-ElfName.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-ElfName 9 | 10 | ## SYNOPSIS 11 | 12 | Find your inner elf 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | New-ElfName [-Count ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | This command will provide you a random elf name. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> New-ElfName 30 | Elsa Mintypuff 31 | ``` 32 | 33 | ### Example 2 34 | 35 | ```powershell 36 | PS C:\> New-ElfName -count 5 37 | Tammy Bignose 38 | Wizzy Glitterbells 39 | Humperdink Littlegas 40 | Doc Fluffypuff 41 | Nutmeg Zanytoe 42 | ``` 43 | 44 | ## PARAMETERS 45 | 46 | ### -Count 47 | 48 | Specify the number of names to generate up to 50. 49 | 50 | ```yaml 51 | Type: Int32 52 | Parameter Sets: (All) 53 | Aliases: 54 | 55 | Required: False 56 | Position: Named 57 | Default value: 1 58 | Accept pipeline input: False 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ### CommonParameters 63 | 64 | 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). 65 | 66 | ## INPUTS 67 | 68 | ### None 69 | 70 | ## OUTPUTS 71 | 72 | ### System.String 73 | 74 | ## NOTES 75 | 76 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 77 | 78 | ## RELATED LINKS 79 | 80 | [New-PSChristmas]() 81 | -------------------------------------------------------------------------------- /docs/New-PSChristmas.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-PSChristmas 9 | 10 | ## SYNOPSIS 11 | 12 | Create a custom Christmas object 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | New-PSChristmas 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | This is a class-based function that creates a PSChristmas object. You can save this object to a variable and pipe it to other commands in the PSChristmas module. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> New-PSChristmas 30 | 31 | Holiday Message: Vesel Božič 32 | 33 | ElfName List ChristmasDay Days CountDown 34 | ------- ---- ------------ ---- --------- 35 | Snookums Pinkpuff Nice Wednesday 22 22.06:06:09 36 | ``` 37 | 38 | The module uses a custom formatting file for the default output which uses ANSI escape sequences to stylize the output. 39 | 40 | ## PARAMETERS 41 | 42 | ## INPUTS 43 | 44 | ### None 45 | 46 | ## OUTPUTS 47 | 48 | ### PSChristmas 49 | 50 | ## NOTES 51 | 52 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 53 | 54 | ## RELATED LINKS 55 | 56 | [Invoke-Jingle]() 57 | 58 | [Show-PSChristmasMessage]() 59 | -------------------------------------------------------------------------------- /docs/New-PSChristmasGreeting.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # New-PSChristmasGreeting 9 | 10 | ## SYNOPSIS 11 | 12 | Create a Christmas greeting. 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | New-PSChristmasGreeting 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | This command will return a random Christmas greeting, most likely "Merry Christmas" from another language. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> New-PSChristmasGreeting 30 | Meri Kuri 31 | ``` 32 | 33 | ## PARAMETERS 34 | 35 | ## INPUTS 36 | 37 | ### None 38 | 39 | ## OUTPUTS 40 | 41 | ### System.String 42 | 43 | ## NOTES 44 | 45 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 46 | 47 | ## RELATED LINKS 48 | 49 | [New-PSChristmas]() 50 | -------------------------------------------------------------------------------- /docs/Show-PSChristmasMessage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Show-PSChristmasMessage 9 | 10 | ## SYNOPSIS 11 | 12 | Display a hidden message in a Christmas object 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | Show-PSChristmasMessage [[-Christmas] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Display a holiday themed message to the console. This function does not write anything to the pipeline. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Show-PSChristmasMessage 30 | 31 | ___ 32 | / '. 33 | / _..---; 34 | | /__..._/ .--.-. 35 | |.' e e | ___\_|/____ 36 | (_)'--.o.--| | | | 37 | .-( -' = -|____| |____| 38 | / ( |____ ____| 39 | | ( |_ | | __| 40 | | '-.--';/'/__ | | ( | 41 | | '. \ )"";--\ / 42 | \ ; |--' ;.-' 43 | |-.__ ..-'--';..--' 44 | 45 | Merry Xmas, Starlight Dustypants 46 | ``` 47 | 48 | The actual output is written to the console in color. You can also pipe a PSChristmas object to this command. 49 | 50 | ## PARAMETERS 51 | 52 | ### -Christmas 53 | 54 | An object created with New-PSChristmas 55 | 56 | ```yaml 57 | Type: PSChristmas 58 | Parameter Sets: (All) 59 | Aliases: 60 | 61 | Required: False 62 | Position: 0 63 | Default value: None 64 | Accept pipeline input: True (ByValue) 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### CommonParameters 69 | 70 | 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). 71 | 72 | ## INPUTS 73 | 74 | ### PSChristmas 75 | 76 | ## OUTPUTS 77 | 78 | ### none 79 | 80 | ## NOTES 81 | 82 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 83 | 84 | ## RELATED LINKS 85 | 86 | [New-PSChristmas]() 87 | -------------------------------------------------------------------------------- /docs/Write-Festive.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSChristmas-help.xml 3 | Module Name: PSChristmas 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Write-Festive 9 | 10 | ## SYNOPSIS 11 | 12 | Write a festive message to the console 13 | 14 | ## SYNTAX 15 | 16 | ```yaml 17 | Write-Festive [-Text] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | This is a silly command that writes a colorized message to the host. The output is written the host using Write-Host with randomly colored foreground and background colors for each letter and space. 23 | 24 | ## EXAMPLES 25 | 26 | ### Example 1 27 | 28 | ```powershell 29 | PS C:\> Write-Festive "Merry Christmas" 30 | Merry Christmas 31 | ``` 32 | 33 | The output is written the host using Write-Host with randomly colored foreground and background colors for each letter and space. 34 | 35 | ### Example 2 36 | 37 | ```powershell 38 | PS C:\> New-PSChristmasGreeting | Write-Festive 39 | Priecīgus Ziemassvētkus 40 | ``` 41 | 42 | The actual output will be colored. 43 | 44 | ## PARAMETERS 45 | 46 | ### -Text 47 | 48 | Enter a text message 49 | 50 | ```yaml 51 | Type: String 52 | Parameter Sets: (All) 53 | Aliases: 54 | 55 | Required: True 56 | Position: 0 57 | Default value: None 58 | Accept pipeline input: True (ByValue) 59 | Accept wildcard characters: False 60 | ``` 61 | 62 | ### CommonParameters 63 | 64 | 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). 65 | 66 | ## INPUTS 67 | 68 | ### System.String 69 | 70 | ## OUTPUTS 71 | 72 | ### None 73 | 74 | ## NOTES 75 | 76 | ## RELATED LINKS 77 | 78 | [Write-Host]() -------------------------------------------------------------------------------- /en-us/PSChristmas-help.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Get-PSChristmasPresent 6 | Get 7 | PSChristmasPresent 8 | 9 | Get a Christmas present 10 | 11 | 12 | 13 | Run this command to get one or more presents from Santa. 14 | 15 | 16 | 17 | Get-PSChristmasPresent 18 | 19 | Count 20 | 21 | The number of presents to get. 22 | 23 | Int32 24 | 25 | Int32 26 | 27 | 28 | 1 29 | 30 | 31 | 32 | 33 | 34 | Count 35 | 36 | The number of presents to get. 37 | 38 | Int32 39 | 40 | Int32 41 | 42 | 43 | 1 44 | 45 | 46 | 47 | 48 | 49 | None 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | System.String 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 69 | 70 | 71 | 72 | 73 | -------------------------- Example 1 -------------------------- 74 | PS C:\> Get-PSChristmasPresent 75 | Barbie 76 | 77 | 78 | 79 | 80 | 81 | -------------------------- Example 2 -------------------------- 82 | PS C:\> Get-PSChristmasPresent 4 83 | Slippers 84 | EZ Bake Oven 85 | Bicycle 86 | Walkman 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | Invoke-Jingle 97 | Invoke 98 | Jingle 99 | 100 | Play a Christmas tune 101 | 102 | 103 | 104 | The command name explains it all. You can pipe a myChristmas object to this function, otherwise it will create one on the fly. 105 | 106 | 107 | 108 | Invoke-Jingle 109 | 110 | Christmas 111 | 112 | An object created with New-PSChristmas 113 | 114 | myChristmas 115 | 116 | myChristmas 117 | 118 | 119 | None 120 | 121 | 122 | 123 | 124 | 125 | Christmas 126 | 127 | An object created with New-PSChristmas 128 | 129 | myChristmas 130 | 131 | myChristmas 132 | 133 | 134 | None 135 | 136 | 137 | 138 | 139 | 140 | myChristmas 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | None 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 160 | 161 | 162 | 163 | 164 | -------------------------- Example 1 -------------------------- 165 | PS C:\>Invoke-Jingle 166 | Nollaig Chridheil, Diogones Furrylobes 167 | 168 | There is no pipeline output. A message is written to the console using Write-Host. 169 | 170 | 171 | 172 | 173 | 174 | New-PSChristmas 175 | 176 | 177 | 178 | 179 | 180 | 181 | New-ElfName 182 | New 183 | ElfName 184 | 185 | Find your inner elf 186 | 187 | 188 | 189 | This command will provide you a random elf name. 190 | 191 | 192 | 193 | New-ElfName 194 | 195 | Count 196 | 197 | Specify the number of names to generate up to 50. 198 | 199 | Int32 200 | 201 | Int32 202 | 203 | 204 | 1 205 | 206 | 207 | 208 | 209 | 210 | Count 211 | 212 | Specify the number of names to generate up to 50. 213 | 214 | Int32 215 | 216 | Int32 217 | 218 | 219 | 1 220 | 221 | 222 | 223 | 224 | 225 | None 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | System.String 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 245 | 246 | 247 | 248 | 249 | -------------------------- Example 1 -------------------------- 250 | PS C:\> New-ElfName 251 | Elsa Mintypuff 252 | 253 | 254 | 255 | 256 | 257 | -------------------------- Example 2 -------------------------- 258 | PS C:\> New-ElfName -count 5 259 | Tammy Bignose 260 | Wizzy Glitterbells 261 | Humperdink Littlegas 262 | Doc Fluffypuff 263 | Nutmeg Zanytoe 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | New-PSChristmas 272 | 273 | 274 | 275 | 276 | 277 | 278 | New-PSChristmas 279 | New 280 | PSChristmas 281 | 282 | Create a custom Christmas object 283 | 284 | 285 | 286 | This is a class-based function that creates a PSChristmas object. You can save this object to a variable and pipe it to other commands in the PSChristmas module. 287 | 288 | 289 | 290 | New-PSChristmas 291 | 292 | 293 | 294 | 295 | 296 | 297 | None 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | PSChristmas 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 317 | 318 | 319 | 320 | 321 | -------------------------- Example 1 -------------------------- 322 | PS C:\> New-PSChristmas 323 | 324 | Holiday Message: Vesel Božič 325 | 326 | ElfName List ChristmasDay Days CountDown 327 | ------- ---- ------------ ---- --------- 328 | Snookums Pinkpuff Nice Wednesday 22 22.06:06:09 329 | 330 | The module uses a custom formatting file for the default output which uses ANSI escape sequences to stylize the output. 331 | 332 | 333 | 334 | 335 | 336 | Invoke-Jingle 337 | 338 | 339 | 340 | Show-PSChristmasMessage 341 | 342 | 343 | 344 | 345 | 346 | 347 | New-PSChristmasGreeting 348 | New 349 | PSChristmasGreeting 350 | 351 | Create a Christmas greeting. 352 | 353 | 354 | 355 | This command will return a random Christmas greeting, most likely "Merry Christmas" from another language. 356 | 357 | 358 | 359 | New-PSChristmasGreeting 360 | 361 | 362 | 363 | 364 | 365 | 366 | None 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | System.String 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 386 | 387 | 388 | 389 | 390 | -------------------------- Example 1 -------------------------- 391 | PS C:\> New-PSChristmasGreeting 392 | Meri Kuri 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | New-PSChristmas 401 | 402 | 403 | 404 | 405 | 406 | 407 | Show-PSChristmasMessage 408 | Show 409 | PSChristmasMessage 410 | 411 | Display a hidden message in a Christmas object 412 | 413 | 414 | 415 | Display a holiday themed message to the console. This function does not write anything to the pipeline. 416 | 417 | 418 | 419 | Show-PSChristmasMessage 420 | 421 | Christmas 422 | 423 | An object created with New-PSChristmas 424 | 425 | PSChristmas 426 | 427 | PSChristmas 428 | 429 | 430 | None 431 | 432 | 433 | 434 | 435 | 436 | Christmas 437 | 438 | An object created with New-PSChristmas 439 | 440 | PSChristmas 441 | 442 | PSChristmas 443 | 444 | 445 | None 446 | 447 | 448 | 449 | 450 | 451 | PSChristmas 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | none 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell-resources/ 471 | 472 | 473 | 474 | 475 | -------------------------- Example 1 -------------------------- 476 | PS C:\> Show-PSChristmasMessage 477 | 478 | ___ 479 | / '. 480 | / _..---; 481 | | /__..._/ .--.-. 482 | |.' e e | ___\_|/____ 483 | (_)'--.o.--| | | | 484 | .-( -' = -|____| |____| 485 | / ( |____ ____| 486 | | ( |_ | | __| 487 | | '-.--';/'/__ | | ( | 488 | | '. \ )"";--\ / 489 | \ ; |--' ;.-' 490 | |-.__ ..-'--';..--' 491 | 492 | Merry Xmas, Starlight Dustypants 493 | 494 | The actual output is written to the console in color. You can also pipe a PSChristmas object to this command. 495 | 496 | 497 | 498 | 499 | 500 | New-PSChristmas 501 | 502 | 503 | 504 | 505 | 506 | 507 | Write-Festive 508 | Write 509 | Festive 510 | 511 | Write a festive message to the console 512 | 513 | 514 | 515 | This is a silly command that writes a colorized message to the host. The output is written the host using Write-Host with randomly colored foreground and background colors for each letter and space. 516 | 517 | 518 | 519 | Write-Festive 520 | 521 | Text 522 | 523 | Enter a text message 524 | 525 | String 526 | 527 | String 528 | 529 | 530 | None 531 | 532 | 533 | 534 | 535 | 536 | Text 537 | 538 | Enter a text message 539 | 540 | String 541 | 542 | String 543 | 544 | 545 | None 546 | 547 | 548 | 549 | 550 | 551 | System.String 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | None 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | -------------------------- Example 1 -------------------------- 576 | PS C:\> Write-Festive "Merry Christmas" 577 | Merry Christmas 578 | 579 | The output is written the host using Write-Host with randomly colored foreground and background colors for each letter and space. 580 | 581 | 582 | 583 | -------------------------- Example 2 -------------------------- 584 | PS C:\> New-PSChristmasGreeting | Write-Festive 585 | Priecīgus Ziemassvētkus 586 | 587 | The actual output will be colored. 588 | 589 | 590 | 591 | 592 | 593 | Write-Host 594 | 595 | 596 | 597 | 598 | -------------------------------------------------------------------------------- /formats/pschristmas.format.ps1xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | default 14 | 15 | PSChristmas 16 | 17 | 18 | "$([char]27)[3m$($_.Greeting)$([char]27)[0m" 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 21 28 | left 29 | 30 | 31 | 32 | 7 33 | left 34 | 35 | 36 | 37 | 15 38 | center 39 | 40 | 41 | 42 | 5 43 | right 44 | 45 | 46 | 47 | 14 48 | right 49 | 50 | 51 | 52 | 53 | 54 | 55 | ElfName 56 | 57 | 58 | 59 | if ($_.List -eq 'Naughty') { 60 | $i = 199 61 | } 62 | else { 63 | $i = 48 64 | } 65 | "$([char]27)[38;5;$($i)m$($_.List)$([char]27)[0m" 66 | 67 | 68 | 69 | ChristmasDay 70 | 71 | 72 | DaysRemaining 73 | 74 | 75 | CountDown 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /functions/Get-PSChristmasPresent.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PSChristmasPresent { 2 | [cmdletbinding()] 3 | [OutputType([string])] 4 | Param( 5 | [ValidateRange(1, 10)] 6 | [ValidateScript( { 7 | if ($_ -gt 10) { 8 | Throw "Do you want to get on the the naughty list? There is a 10 present limit." 9 | $false 10 | } 11 | else { 12 | $True 13 | } 14 | })] 15 | [int]$Count = 1 16 | ) 17 | 18 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 19 | Write-Verbose "[PROCESS] Getting $count presents" 20 | 21 | $presents = $global:xmasData.Presents | Get-Random -count $Count 22 | 23 | $presents 24 | 25 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 26 | 27 | } 28 | -------------------------------------------------------------------------------- /functions/Invoke-Jingle.ps1: -------------------------------------------------------------------------------- 1 | Function Invoke-Jingle { 2 | [cmdletbinding()] 3 | [OutputType('none')] 4 | [alias('jingle')] 5 | 6 | Param( 7 | [Parameter(Position = 0, ValueFromPipeline)] 8 | [PSChristmas]$Christmas = $(New-PSChristmas) 9 | ) 10 | 11 | Begin { 12 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 13 | } #begin 14 | 15 | Process { 16 | if ($IsWindows -OR $PSEdition -eq 'desktop') { 17 | Write-Verbose "[PROCESS] Using Christmas object for $($christmas.ElfName)" 18 | Write-Festive "$($christmas.greeting), $($Christmas.ElfName)" 19 | $Christmas.Play() 20 | } 21 | else { 22 | Write-Warning 'Invoke-Jingle is only available on Windows systems.' 23 | } 24 | } #process 25 | 26 | End { 27 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 28 | } #end 29 | 30 | } 31 | -------------------------------------------------------------------------------- /functions/New-ElfName.ps1: -------------------------------------------------------------------------------- 1 | Function New-ElfName { 2 | [cmdletbinding()] 3 | [OutputType([string])] 4 | [alias("elfme")] 5 | 6 | Param ( 7 | [Parameter(HelpMessage = "Specify the number of names to generate up to 50.")] 8 | [ValidateRange(1, 50)] 9 | [int]$Count = 1 10 | ) 11 | 12 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 13 | Write-Verbose "[BEGIN ] Creating $count name(s)" 14 | #insert a sleep if generating more than one name to increase randomization 15 | if ($count -gt 1) { 16 | #milliseconds 17 | $sleep = 250 18 | } 19 | else { 20 | $sleep = 0 21 | } 22 | Try { 23 | [void](Get-Variable -Name xmasData -Scope global -ErrorAction Stop) 24 | 25 | 1..$Count | ForEach-Object { 26 | $name = "{0} {1}{2}" -f (Get-Random $global:xmasData.FirstNames), (Get-Random $global:xmasData.Modifiers), (Get-Random $global:xmasData.LastNames) 27 | Start-Sleep -Milliseconds $sleep 28 | Write-Verbose "[PROCESS] Created name $name" 29 | #return the result 30 | $name 31 | } 32 | } 33 | Catch { 34 | Write-Warning "Failed to find the `xmasdata` variable from the PSChristmas module. $($_.exception.message)" 35 | } 36 | 37 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 38 | 39 | } 40 | -------------------------------------------------------------------------------- /functions/New-PSChristmas.ps1: -------------------------------------------------------------------------------- 1 | Function New-PSChristmas { 2 | [cmdletbinding()] 3 | [OutputType("PSChristmas")] 4 | Param() 5 | 6 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 7 | 8 | #New-Object -TypeName PSChristmas 9 | [PSChristmas]::New() 10 | 11 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 12 | } 13 | -------------------------------------------------------------------------------- /functions/New-PSChristmasGreeting.ps1: -------------------------------------------------------------------------------- 1 | Function New-PSChristmasGreeting { 2 | [cmdletbinding()] 3 | [OutputType([string])] 4 | Param() 5 | 6 | Begin { 7 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 8 | } 9 | Process { 10 | Try { 11 | [void](Get-Variable xmasData -ErrorAction Stop) 12 | $global:xmasData.Greeting | Get-Random -count 1 13 | } 14 | Catch { 15 | Write-Warning "Failed to find the `xmasData` variable from the PSChristmas module." 16 | } 17 | } 18 | End { 19 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /functions/Show-PSChristmasMessage.ps1: -------------------------------------------------------------------------------- 1 | Function Show-PSChristmasMessage { 2 | [cmdletbinding()] 3 | [OutputType("none")] 4 | Param( 5 | [Parameter(Position = 0, ValueFromPipeline)] 6 | [PSChristmas]$Christmas = $(New-PSChristmas) 7 | ) 8 | 9 | Begin { 10 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 11 | } #begin 12 | 13 | Process { 14 | Write-Verbose "[PROCESS] Using Christmas object for $($christmas.ElfName)" 15 | $Christmas.Show() 16 | 17 | $msg = "`n`t{0}, {1}" -f $Christmas.Greeting, $Christmas.ElfName 18 | Write-Festive $msg 19 | } #process 20 | 21 | End { 22 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 23 | } #end 24 | 25 | } 26 | -------------------------------------------------------------------------------- /functions/Write-Festive.ps1: -------------------------------------------------------------------------------- 1 | Function Write-Festive { 2 | [cmdletbinding()] 3 | [OutputType("None")] 4 | [alias("wf")] 5 | 6 | Param( 7 | [Parameter(Position = 0, Mandatory, HelpMessage = "Enter a text message", ValueFromPipeline)] 8 | [ValidateNotNullOrEmpty()] 9 | [string]$Text 10 | ) 11 | 12 | Begin { 13 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 14 | $colors = ([enum]::GetNames([System.ConsoleColor])).Where( { $_ -ne $host.ui.RawUI.BackgroundColor }) 15 | } #begin 16 | 17 | Process { 18 | 19 | $Text.ToCharArray() | ForEach-Object -begin { 20 | #define a hashtable of parameters to splat to Write-Host 21 | $ParamHash = @{NoNewLine = $True; } 22 | } -process { 23 | #use a color if not a space 24 | if ($_ -notmatch "\s") { 25 | $ParamHash.ForegroundColor = (Get-Random -InputObject $colors -count 1) 26 | $ParamHash.BackgroundColor = do { 27 | #get a background color that is different than the 28 | #ForeGroundColor 29 | Get-Random -InputObject $colors -Count 1 30 | } until($_ -ne $ParamHash.ForegroundColor) 31 | } #if not whitespace 32 | else { 33 | #clear colors 34 | $ParamHash.Remove("ForegroundColor") 35 | $ParamHash.Remove("BackgroundColor") 36 | } 37 | #write each character to the host 38 | $_ | Write-Host @ParamHash 39 | 40 | } -end { "`n" } 41 | 42 | } #Process 43 | 44 | End { 45 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /functions/helpers.ps1: -------------------------------------------------------------------------------- 1 | #these are private helper functions 2 | 3 | Function PlayTune { 4 | [cmdletbinding()] 5 | [OutputType("none")] 6 | Param() 7 | 8 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 9 | 10 | <# 11 | The first number is the reciprocal of the duration and the rest is the 12 | note and octave (which we use for getting the frequency). 13 | For example, 4A4 is a quarter A note 14 | #> 15 | 16 | #first verse only 17 | $notes = Write-Output 4A4 4A4 2A4 4A4 4A4 2A4 4A4 4C4 4F3 8G3 1A4 ` 18 | 4Bb4 4Bb4 4Bb4 8Bb4 4Bb4 4A4 4A4 8A4 8A4 4A4 4G3 4G3 4A4 2G3 2C4 ` 19 | 4A4 4A4 2A4 4A4 4A4 2A4 4A4 4C4 4F3 4G3 1A4 4Bb4 4Bb4 4Bb4 4Bb4 ` 20 | 4Bb4 4A4 4A4 8A4 8A4 4C4 4C4 4Bb4 4G3 1F3 21 | 22 | function Play([int] $freq, [int] $duration) { 23 | [console]::Beep($freq, $duration) 24 | } 25 | 26 | function GetNoteFreq([string]$note) { 27 | # n is the number of half steps from the fixed note. 28 | $note -match '([A-G#]{1,2})(\d+)' | Out-Null 29 | $octave = ([int] $matches[2]) - 4 30 | $n = $octave * 12 + ( GetHalfStepsFromA $matches[1] ) 31 | $freq = $f0 * [math]::Pow($a, $n) 32 | 33 | return $freq 34 | } 35 | 36 | function GetHalfStepsFromA([string] $note) { 37 | switch ($note) { 38 | 'A' { 0 } 39 | 'A#' { 1 } 40 | 'Bb' { 1 } 41 | 'B' { 2 } 42 | 'C' { 3 } 43 | 'C#' { 4 } 44 | 'Db' { 4 } 45 | 'D' { 5 } 46 | 'D#' { 6 } 47 | 'Eb' { 6 } 48 | 'E' { 7 } 49 | 'F' { 8 } 50 | 'F#' { 9 } 51 | 'Gb' { 9 } 52 | 'G' { 10 } 53 | 'G#' { 11 } 54 | 'Ab' { 11 } 55 | } 56 | } 57 | 58 | 59 | # 60 | # Note is given by fn=f0 * (a)^n 61 | # a is the twelfth root of 2 62 | # n is the number of half steps from f0, positive or negative. 63 | # f0 used here is A4 at 440 Hz 64 | # 65 | $f0 = 440; 66 | $a = [math]::pow(2, (1 / 12)) # Twelfth root of 2 67 | 68 | 69 | $StandardDuration = 1000 70 | foreach ($note in $notes) { 71 | 72 | $note -match '(\d)(.+)' | Out-Null 73 | $duration = $StandardDuration / ([int] $matches[1]) 74 | $playNote = $matches[2] 75 | $freq = GetNoteFreq $playNote 76 | 77 | Play $freq $duration 78 | Start-Sleep -Milliseconds 50 79 | } 80 | 81 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 82 | 83 | } 84 | 85 | Function ShowGraphic { 86 | [cmdletbinding()] 87 | [OutputType("none")] 88 | Param() 89 | 90 | # Clear-Host 91 | 92 | Write-Verbose "[BEGIN ] Starting: $($MyInvocation.MyCommand)" 93 | 94 | $Msg1 = 95 | @" 96 | .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:. 97 | . * . 98 | . /.\ Merry Christmas . 99 | . /..'\ from all of us . 100 | . /'.'\ in PowerShell . 101 | . /.''.'\ . 102 | . /.'.'.\ . 103 | . /'.''.'.\ . 104 | . ^^^[_]^^^ . 105 | . . 106 | . . 107 | . . 108 | .:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:._.:*~*:. 109 | "@ 110 | 111 | 112 | $Msg2 = 113 | @" 114 | _... 115 | o_.-"` `\ 116 | .--. _ `'-._.-'""-; _ 117 | .' \`_\_ {_.-a"a-} _ / \ 118 | _/ .-' '. {c-._o_.){\|` | 119 | (@`-._ / \{ ^ } \\ _/ 120 | `~\ '-._ /'. } \} .-. 121 | |>:< '-.__/ '._,} \_/ / ()) 122 | | >:< `'---. ____'-.|(`"` 123 | \ >:< \\_\\_\ | ; 124 | \ \\-{}-\/ \ 125 | \ '._\\' /) 126 | '. /( 127 | `-._ _____ _ _____ __.'\ \ 128 | / \ / \ / \ \ \ 129 | _.'/^\'._.'/^\'._.'/^\'.__) \ 130 | ,==' `---` '---' '---' ) 131 | `"""""""""""""""""""""""""""""""` 132 | "@ 133 | 134 | $msg3 = 135 | @" 136 | ___ 137 | /` `'. 138 | / _..---; 139 | | /__..._/ .--.-. 140 | |.' e e | ___\_|/____ 141 | (_)'--.o.--| | | | 142 | .-( `-' = `-|____| |____| 143 | / ( |____ ____| 144 | | ( |_ | | __| 145 | | '-.--';/'/__ | | ( `| 146 | | '. \ )"";--`\ / 147 | \ ; |--' `;.-' 148 | |`-.__ ..-'--'`;..--'` 149 | "@ 150 | 151 | $msg4 = 152 | @" 153 | * , 154 | _/^\_ 155 | < > 156 | * /.-.\ * 157 | * `/&\` * 158 | ,@.*;@, 159 | /_o.I %_\ * 160 | * (`'--:o(_@; 161 | /`;--.,__ `') * 162 | ;@`o % O,*`'`&\ 163 | * (`'--)_@ ;o %'()\ * 164 | /`;--._`''--._O'@; 165 | /&*,()~o`;-.,_ `""`) 166 | * /`,@ ;+& () o*`;-';\ 167 | (`""--.,_0 +% @' &()\ 168 | /-.,_ ``''--....-'`) * 169 | * /@%;o`:;'--,.__ __.'\ 170 | ;*,&(); @ % &^;~`"`o;@(); * 171 | /(); o^~; & ().o@*&`;&%O\ 172 | `"="==""==,,,.,="=="==="` 173 | __.----.(\-''#####---...___...-----._ 174 | '` \)_`"""""` 175 | .--' ') 176 | o( )_-\ 177 | `"""` ` 178 | 179 | "@ 180 | 181 | $msg5 = 182 | @" 183 | .--------. 184 | * . |________| . * 185 | | __|/\ 186 | * .-'======\_\o/. 187 | /___________<>__\ 188 | |||||| / (o) (o) \ 189 | |||||| | _ O _ | . 190 | . |||||| | (_) (_) | 191 | |||||| \ '---' / * 192 | \====/ [~~~~~~~~~] 193 | \\// _/~||~`|~~~~~\_ 194 | _||-'`/ || | \`'-._ * 195 | * .-` )| ; || |) ; '. 196 | / `--.| || | | `\ 197 | | \ |||||) |-, \ . 198 | \ .; _ ; |_, | 199 | `'''||` ,\ (_) /, `.__/ 200 | ||.` '. .' `. * 201 | * || ` ' ' ` \ 202 | || ; 203 | . * || | . 204 | || | * 205 | || | 206 | .__.-""-.__.-"""|| ;.-"""-.__.-""-.__. 207 | || / 208 | ||'. .' 209 | || '-._ _ _ _ _.-' 210 | `""` 211 | "@ 212 | $msg6 = 213 | @" 214 | _ 215 | .-(_) 216 | / _/ 217 | .-' \ 218 | / '. 219 | ,-~--~-~-~-~-, 220 | {__.._...__..._} ,888, 221 | ,888, /\##" 6 6 "##/\ ,88' `88, 222 | ,88' '88,__ |(\` (__) `/)| __,88' `88 223 | ,88' .8(_ \_____\_ '----' _/_____/ _)8. 8' 224 | 88 (___)\ \ '-.__ __.-' / /(___) 225 | 88 (___)88 | '--' | 88(___) 226 | 8' (__)88,___/ \___,88(__) 227 | __`88,_/__________________\_,88`__ 228 | / `88, |88| ,88' \ 229 | / `88, |88| ,88' \ 230 | /____________`88,_\88/_,88`____________\ 231 | /88888888888888888;8888;88888888888888888\ 232 | /^^^^^^^^^^^^^^^^^^`/88\\^^^^^^^^^^^^^^^^^^\ 233 | / |88| \============, \ 234 | /_ __ __ __ _ __ |88|_|^ MERRY | _ ___\ 235 | |;:. |88| | CHRISTMAS! | | 236 | |;;:. |88| '============' | 237 | |;;:. |88| | 238 | |::. |88| | 239 | |;;:' |88| | 240 | |:;, |88| | 241 | '---------------------""""---------------------' 242 | "@ 243 | 244 | $i = Get-Random -Minimum 1 -Maximum 6 245 | 246 | $selected = ($msg1, $msg2, $msg3, $msg4, $msg5, $msg6 | Get-Random) 247 | If ([bool]!($i % 2)) { 248 | Write-Host -ForegroundColor Green -Object $selected 249 | 250 | } 251 | else { 252 | Write-Host -ForegroundColor Red -Object $selected 253 | } 254 | 255 | Write-Verbose "[END ] Ending: $($MyInvocation.MyCommand)" 256 | 257 | } --------------------------------------------------------------------------------