Last active
December 1, 2017 15:58
-
-
Save jdhitsolutions/a878b285fcf0ec888c02 to your computer and use it in GitHub Desktop.
Generate a fictious name that might exist in the Star Wars universe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#generate a fictious name that might exist in the Star Wars universe. | |
[cmdletbinding()] | |
Param( | |
[Parameter(Mandatory,HelpMessage="Enter your first name. It must be at least 2 characters")] | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript({$_.length -ge 2})] | |
[String]$Name, | |
[Parameter(Mandatory,HelpMessage="Enter your Mother's first name. It must be at least 2 characters")] | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript({$_.length -ge 2})] | |
[String]$Mother, | |
[Parameter(Mandatory,HelpMessage="Enter your Father's first name. It must be at least 2 characters")] | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript({$_.length -ge 2})] | |
[String]$Father, | |
[Parameter(Mandatory,HelpMessage="What state or city were you born in? It must be at least 4 characters and remove spaces.")] | |
[ValidateScript({$_.length -ge 4})] | |
[string]$State | |
) | |
#get a random console color name | |
$color = [enum]::GetNames([consolecolor]) | Get-Random | |
#use the -F operator to assemble first and last names using the Substring method. | |
$first = "{0}{1}{2}{3}" -f $name.substring(0,1).toUpper(),$name.substring(1,1),$mother.Substring(0,2),$father.Substring($father.Length -2,2) | |
$last = "{0}{1}" -f $color.Substring(0,3),$state.Substring($state.length -4,4) | |
#join the first and last name together | |
$yourname = $first,$last -join " " | |
#display the results. | |
Write-Host "Greetings, $yourname. At last we meet again." -ForegroundColor Cyan | |
<# | |
Copyright (c) 2016-2017 JDH Information Technology Solutions, Inc. | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in | |
all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Published at https://jdhitsolutions.com/blog/powershell/5799/friday-fun-a-long-time-ago-in-a-powershell-universe-far-far-away/