Random Word Function


In order to test some websites I had need to have a function that produced random words.

I found this random word Json list. https://raw.githubusercontent.com/RazorSh4rk/random-word-api/master/words.json

And decided to wrap a small function around it:


function Get-RandomWord
{
if(-not $words)
{

$Script:words = (invoke-webrequest -Uri https://raw.githubusercontent.com/RazorSh4rk/random-word-api/master/words.json).content | convertfrom-json

}

$words["$(get-random -Maximum ($words.count))"]
}

 

if you wish to change to your own list of random words just change the json location to a local directory with a json file or a different web url that contains the json you want to Randomize.

 

Until then

I hope this helps someone

 

thom

3 thoughts on “Random Word Function

  1. Malcolm Chalmers

    Thanks.
    I tried to get the API suggested by CRSHNBRN66 working as well, but couldn’t.
    Your script however works great every time.
    thanks.

    Like

Leave a comment