Technical Article

Generate password using PowerShell

,

Open PowerShell in Admin mode

Copy the script

Run it.

clear-host
$ascii=$NULL;For ($a=33;$a –le 126;$a++) {$ascii+=,[char][byte]$a }
Function GET-Temppassword() {

Param(

[int]$length=10,

[string[]]$sourcedata


)



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

            }

return $TempPassword

}

write-host "Your Random Generated Password Is below: `n `r" -ForegroundColor GRAY
$password1 = (GET-Temppassword –length 19 –sourcedata $ascii )
$password2 = (GET-Temppassword –length 19 –sourcedata $ascii )
$password3 = (GET-Temppassword –length 19 –sourcedata $ascii )

write-host "`n `rPASSWORD1: `r" 
write-host $password1  -ForegroundColor YELLOW

write-host "`n `rPASSWORD2: `r" 
write-host $password2  -ForegroundColor GREEN

write-host "`n `rPASSWORD3: `r" 
write-host $password3  -ForegroundColor CYAN

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating