Advertisement
Merzavets

PoSh Password generator

Nov 21st, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $newp = ''
  2. $passlen = 7
  3. 1..$passlen | `
  4. foreach `
  5.     {
  6.         switch (Get-Random -Minimum 0 -Maximum 3)
  7.         {
  8.             0 { $newp += [char](Get-Random -Minimum 0x30 -Maximum 0x39) }
  9.             1 { $newp += [char](Get-Random -Minimum 0x41 -Maximum 0x5a) }
  10.             2 { $newp += [char](Get-Random -Minimum 0x61 -Maximum 0x7a) }
  11.         }
  12.     }
  13. " "; $newp; " "
  14.  
  15. #  Next approach maybe better, will try it sometime :-)
  16. #  $rand = New-Object System.Random
  17. #
  18. #  $NewPassword += [char]$rand.next(65,90)
  19. # [...]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement