Advertisement
Guest User

Random-PW

a guest
Aug 25th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # I know I know... The veriables for Read-Host should be be parameters... but
  2. # that's for another day. At least it errors out when someone types a char instead
  3.  
  4. $chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+=-'
  5. [int]$numberPassword = Read-Host -Prompt 'How many passwords?'
  6. [int]$lengthPassword = Read-Host -Prompt "Length of passwords?"
  7.  
  8. for ($i = 0; $i -lt $numberPassword; $i++) {
  9.     $pw = Get-Random -InputObject $chars.ToCharArray() -Count $lengthPassword
  10.     $finalPassword = -join $pw
  11.     Write-Output $finalPassword
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement