PowerShell Fortune Cookie
Ahead of writing a post about writing a fortune cookie cmdlet in C#, I wanted to post the simplest possible implementation in PowerShell first.
Get-FortuneCookie.ps1
[CmdletBinding()]
Param (
[Parameter()]
[string]$Path = '<Default Path>\fortunes.txt'
)
$CookieJar = Get-Content $Path -Encoding UTF8 -Delimiter '%'
$Cookie = Get-Random -InputObject $CookieJar
$Cookie = $Cookie -replace '%', ''
Write-Output $Cookie