PowerShell: Create random password function V3.

A while ago I wrote this, which in turn was an improvement on this. This is a slight improvement on the previous version in that it uses a slightly different word API that gives us more options as regards word length making the over all result a little more memorable the end user. I have also put it in a function to allow you to embed it into your own code more easily.

So now we have the all new random password generator V3!

    Function Get-RandomWord() # First I define something to get a random word
    {
    $RAWword = (invoke-WebRequest -Uri https://random-word-api.herokuapp.com/word?length=5).content    #some random word website  
    $word = $RAWword.Trim('[','"','"',']') #Tidy up the results 
    return $word #Here's your word
    }


    Function Get-SecurePassword()

    {
    $length = 1 # The amount of the characters and numbers
    $FirstWord = Get-RandomWord #Get first word
    $SecondWord = Get-RandomWord #Get second word

    $ascii=$NULL
    For ($a=48;$a –le 57;$a++) {$ascii+=,[char][byte]$a } #Number
    For ($a=33;$a –le 38;$a++) {$Char+=,[char][byte]$a } #Some special characters
 
    $TempPassword = ($FirstWord |GET-RANDOM)
   

    For ($loop=1; $loop –le $length; $loop++) 
            {
            $TempPassword+=($ascii| GET-RANDOM)
            }

    For ($loop=1; $loop –le $length; $loop++) 
           {
            $TempPassword+=($ascii| GET-RANDOM)
           }

    $TempPassword += ($SecondWord |GET-RANDOM)

       For ($loop=1; $loop –le $length; $loop++) 
           {
            $TempPassword+=($Char| GET-RANDOM)
           }

    return $TempPassword # Your password
    }

here are a few examples of it in action.