Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I need a powershell script that's i'm guessing will use the get-random command to create a random password (which I actually have and works).

 

I need it to create a password that's a minimum of 8 characters (which again it does)

 

But it also need to create a password that contains at least 1 Upper, 1 lower and 1 number (which I'm struggling with)

 

Currently I have

 

function GeneratePassword

{

PARAM( [int]$PasswordLength )

PROCESS

{

$alphabet = @("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0");

$password = $( $alphabet | Get-Random -Count $PasswordLength ) -join ""

return $password;

}

}

 

$password=GeneratePassword 8

 

I'm guessing I somehow need to create groups or characters and force it to use at least 1 from each....any help appreciated

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...