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
Hey, uh, if you wanted to just get one word and would do a webrequest every time anyway, you could have just used
https://random-word-api.herokuapp.com/word?number=1
LikeLike
Yes I could have. I had to use this in a place i couldn’t get to the api everytime.
LikeLike