{"id":16567529,"url":"https://github.com/jdhitsolutions/psnonsense","last_synced_at":"2026-06-01T04:31:50.842Z","repository":{"id":145020773,"uuid":"285842377","full_name":"jdhitsolutions/PSNonsense","owner":"jdhitsolutions","description":"My solution to the Iron Scripter PowerShell challenge described at  https://ironscripter.us/a-powershell-nonsense-challenge/.","archived":false,"fork":false,"pushed_at":"2020-08-07T15:01:02.000Z","size":251,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-01T23:36:41.146Z","etag":null,"topics":["powershell","scripting"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhitsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-07T13:59:48.000Z","updated_at":"2023-03-21T07:33:31.000Z","dependencies_parsed_at":"2023-05-02T05:02:23.767Z","dependency_job_id":null,"html_url":"https://github.com/jdhitsolutions/PSNonsense","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jdhitsolutions/PSNonsense","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSNonsense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSNonsense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSNonsense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSNonsense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhitsolutions","download_url":"https://codeload.github.com/jdhitsolutions/PSNonsense/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSNonsense/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33760645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["powershell","scripting"],"created_at":"2024-10-11T21:06:52.180Z","updated_at":"2026-06-01T04:31:50.827Z","avatar_url":"https://github.com/jdhitsolutions.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSNonsense\n\n![Iron Scripter](images/IronScripterLogo.png)\n\nThis module contains my solution to the Iron Scripter PowerShell challenge described at https://ironscripter.us/a-powershell-nonsense-challenge/. The point of these challenges isn't the final result. That's certainly the case with this challenge. Rather the value is learning how to use PowerShell, and maybe discovering a new technique or command. The hope is that during the course of working on the challenge, you'll improve your PowerShell scripting skills. And who knows, maybe even have a little fun along the way.\n\n\u003e *This was never intended as a production level module, so even though there is help documentation, it has not been completed.*\n\n## Answering the Challenge\n\nThese were some of the specific challenge requirements.\n\n### Create a random, nonsense word of a user specified length\n\n```powershell\nNew-NonsenseWord -Length 7\n```\n\n### Create a sentence of random words of a user specified length.\n\nWords should be of varying lengths.\n\n```powershell\nNew-NonsenseSentence -WordCount 11\n```\n\n### Create a paragraph of random sentences of user specified length\n\nSentences should be of varying lengths.\n\n```powershell\nNew-NonsenseParagraph -SentenceCount 7\n```\n\n### Create 10 sample document files of varying paragraph length\n\n```powershell\n1..10 | ForEach-Object {\n    $filename = [System.IO.Path]::GetRandomFileName()\n    #replace the extension\n    $filename = $filename -replace \"\\.\\w+\", \".txt\"\n    #build the path\n    $path = Join-Path -path $env:TEMP -ChildPath $filename\n    #create the document\n    #encode as UTF8 to save the diacritical characters\n    New-NonsenseDocument -ParagraphCount (Get-Random -Minimum 3 -Maximum 10) | \n    Out-File -FilePath $path -Encoding utf8\n    #view the result\n    Get-Item $path\n}\n```\n\n### Create a command to create a nonsense markdown document\n\nI created these helper, or cheater, functions to simplify the process. I could have included them in this module but decided not. All of this code could be wrapped up in a single script file. The spacings are important to create a proper markdown document.\n\n```powershell\n#cheater functions\nfunction New-Heading {\n    (New-NonsenseSentence -WordCount (Get-Random -Minimum 1 -Maximum 5)) -replace \"[.!?]\", \"\"\n}\n\nfunction New-CodeFence {\n    $cmd = \"$((New-NonsenseSentence -WordCount (Get-Random -Minimum 2 -Maximum 6)) -replace \"[.!?]\",'')\"\n\n    #the backtick needs to be escaped so that end result is a proper markdown code fence.\n    #there should be 6 backticks.\n    $cf = @\"\n$('`'*6)powershell\nPS C:\\\u003e $cmd\n$('`'*6)\n\"@\n    $cf\n}\n\nfunction New-SubHead {\n    Param(\n        [int]$Level = 2\n    )\n\n    $h = \"#\"*$level\n    $head = \"{0} {1}\" -f $h, (New-Heading)\n    #write-host $head -ForegroundColor red\n    $out = @\"\n$head\n\n\n\"@\n\n    1..(Get-Random -Maximum 4) | ForEach-Object {\n\n        $p = (New-NonsenseParagraph -SentenceCount (Get-Random -Minimum 4 -Maximum 10) -outvariable pv)\n\n        if ((Get-Random)%3) {\n            #randomly format a string\n            $wds = ($p.split()).where( {$_ -match \"\\w+\"})\n            $hl = $wds | Select-Object -skip (Get-Random -Minimum 7 -Maximum ($wds.count - 20)) -First (Get-Random -Minimum 1 -Maximum 7)\n\n            #randomly decide how to format\n            Switch ((Get-Random)) {\n                {$_%3} {$f = \"*$($hl -join \" \")*\" }\n                {$_%5} {$f = \"__$($hl -join \" \")__\"}\n                {$_%7} {$f = \"__*$($hl -join \" \")*__\" }\n                {$_%4} {$f = \"``$($hl -join \" \")``\" }\n                {$_%2} {$f = \"[$($hl -join \" \")](https://www.$(New-NonsenseWord).com)\"}\n            }\n            #left justify to send to the here string to avoid extra spaces\n            $out += ($p -replace ($hl -join \" \"), $f)\n        } #if %3\n        else {\n            $out += $p\n        }\n\n        $out += \"`n`n\"\n\n        \u003c#\n        the out variable is itself an array. I want to get the first item in that array,\n        which will be a string and then the first character in that string.\n        #\u003e\n        if ($pv[0][0] -match \"[aeifuylm]\") {\n            #$out+=\"`n\"\n            #increment if the next level is 4 or less\n            if ($level + 1 -le 4) {\n                $out += New-SubHead -level ($level + 1)\n            }\n            else {\n                #repeat the level\n                $out += New-SubHead -level $level\n            }\n        }\n        elseif ($pv[0][0] -match \"[pjqrst]\" ) {\n\n            $out += New-CodeFence\n            $out += \"`n`n\"\n            #add a bit more verbiage\n            $out += New-NonsenseParagraph -SentenceCount (Get-Random -Minimum 1 -Maximum 4)\n        }\n    } #foreach object\n\n    $out\n\n} #New-SubHead\n```\n\nWith these functions, and assuming this module is loaded, I can build a here-string of a markdown document and save it to a file.\n\n```powershell\n$md = @\"\n# $(New-Heading)\n\n$((New-SubHead).trimend())\n\n__My additional New-Headings follow.__\n\n\n\"@\n\n1..(Get-Random -maximum 5) | ForEach-Object {\n    $md += New-SubHead\n}\n\n$md += \"Updated *$(Get-Date)*.\"\n\n$md\n#encode as UTF8 to save the diacritical characters\n$md | Out-File -FilePath c:\\work\\nonsense.md -Encoding utf8\n```\n\nEncoding the file at `UTF8` is important if you are using diacritic characters. If you open the file in VS Code, the editor will show the correct text. But the markdown preview does not.\n\nLast updated *2020-08-07 14:53:15Z UTC*.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2Fpsnonsense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhitsolutions%2Fpsnonsense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2Fpsnonsense/lists"}