þÿ# Get-Password # # Genera contraseñas aleatorias de tamaño dinámico. # # Copyright (C) Victor Lozano 2011 # victor.lozano@mildecabeza.com # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # function Get-Password { #Parámetros de la función. param ($length) #Se crea un objeto random. $random = New-Object System.Random #Caracteres permitidos en la contraseña. $simbols = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" #Se genera una contraseña de longitud dinámica. 1..[int] $length | foreach { $password = $password + $simbols[$random.next(0,62)] } #Se retorna la contraseña creada. return $password } #Ejemplo de uso. Get-Password 10