powershell - Password with word and 4 generated characters -


i've following script , want generate password pattern temppw + 3 numbers , 1 special character. have change in script?

# # description: wlacza konta, resetuje hasla ustawia zmiane hasla przy pierwszym logowaniu. # import-module activedirectory add-type -assemblyname system.web  # pobiera liste kont z pliku userlist.txt # jeden user na wiersz, bo sie wysypie.  $users = get-content -path 'g:\shares\xx xxx\resetpassword\userlist.txt' # foreach ($user in $users)  { $unsecuredpwd = [system.web.security.membership]::generatepassword(10, 3) # szyfruje haslo, potem podstawia je w miejsce zmiennej unsecurepwd. $password = convertto-securestring -asplaintext $unsecuredpwd -force # ustawia haslo dla konta. get-aduser $user | set-adaccountpassword -newpassword $password -reset # wymusza zmiane hasla przy logowaniu. get-aduser $user | set-aduser -changepasswordatlogon $true # wlacza konto. enable-adaccount -identity $user write-host “uzytkownik: $user” write-host “haslo: $unsecuredpwd” write-host “ `r`n`r`n” } read-host -prompt "nacisnij enter, zeby wyjsc" 

generating random 3 digit number easy, use get-random -minimum , -maximum parameters:

# maximum exclusive, largest potential output 999  $randomnumber = get-random -minimum 100 -maximum 1000 

generating random "special character" easy well, can grab 1 of symbols ascii range between 33 , 47 (! " # $ % & ' ( ) * + , - . /):

$randomspecialchar = [char](33..47 |get-random) 

so generate whole password, can use string format operator (-f) , do:

$unsecuredpwd = "temppw{0}{1}" -f (get-random -minimum 100 -maximum 1000),[char](33..47 |get-random) 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -