Jump to content

Recommended Posts

Posted

As Per title, We need to set supply accounts to reset password on a daily basis and generate a random password + force password change- is there anything I can use for this?

 

Thanks

Posted (edited)

Do you use Salamander?

Otherwise, you can do it in Powershell, with a scheduled task.

Creates a random 12 character string for the password then sets it.

$password = -join (((48..57)+(65..90)+(97..122)) * 80 |Get-Random -Count 12 |%{[char]$_})
Set-ADAccountPassword -Identity [username] -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $password -Force)
set-aduser [username] -ChangePasswordAtLogon:$true

 

My Powershell is poor, but this should work. Test it.

 

https://gist.github.com/gregjhogan/2350eb60d02aa759c9d269c3fc6265b1

Edited by 3s-gtech
  • Thanks 1
  • 5 months later...
Posted

Before I moved to the cloud, this ran as a scheduled task on my DC each night...

 

### Generates a request via the DinoPass API for a random simple password
$Password_Part1 = Invoke-WebRequest -Uri https://www.dinopass.com/password/simple | Select-Object -ExpandProperty content
### Generates a date in day-2digitmonth-4digityear
$Password_Part2 = Get-Date -format "dd-MM-yyyy"
### Concatenates the 2 into one variable
$Password_Complete ="$Password_Part1$Password_Part2"
### Writes the output to text file so you have a local reference - can be omitted.
$Password_Complete | Out-File C:\YourFileLocation\value.txt
### Resets the specified account password to the value contained within $Password_Complete
Set-ADAccountPassword -Identity UserName -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "$Password_Complete" -Force)
### Emails the new password
### Email address to send from 
$username = "[email protected]"
### Email Password
$Password = "ComplexEmailPassword"
### Converts plaintext password above to a secure string
$Password = ConvertTo-SecureString -String $Password -AsPlainText -Force
### Creates a credential object to call later
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $Password
### Specifies email subject
$subject = 'Alert: New Password'
### Specifies Email body
$body = $Password_Complete

### Splatting with Hash Table

$hash = @{

To = '[email protected]'
From = $username
Subject = $subject
Body = $body
BodyAsHtml = $true
SmtpServer = 'smtp.office365.com'
UseSSL = $true
Credential = $cred
Port = 587

}

### Sends Mail
Send-MailMessage  @hash -WarningAction Ignore 

 

Email was sent to the office email account as they were the one's who did meet n greet with supply staff.

  • Thanks 2

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...