Let´s say we have the following scenario: NB: Goes without saying – but this method of changing password and sending them via e-mail wont work if the users dont have access to the mail with their current password – and thus is not a good method for changing passwords on users current AD/Exchange-account. To make it more interesting we can also send this password in an e-mail, granted we have the e-mail address of the users. Setting a new password, and then bulk sending information e-mail to users This example creates a password with 8 characters/numbers in total, then selects AD-user from the “Test OU”, and sets the password and making the user have to change password on next logon – in the end writing the UPN and Password to password.txt-file. #logging results – so that admin could manually send the password to users. Get-ADUser -SearchBase $UserOU -Filter -Properties * | Set-ADAccountPassword -NewPassword $NewPassword -Reset -PassThru | Set-ADuser -ChangePasswordAtLogon $True $UserPrincipalName = New-RandomPassword 8 $UserOU = "OU=Test OU,OU=Users,DC=Fabricam,DC=com" For Active Directory we have the Set-ADAccountPassword cmdlet that can help us achieve this:Įxample: Create and Set a Random Password in ADĪfter importing the New-RandomPassword cmdlet – For a user we can do: Note: If you need even more complex passwords i would suggest looking for complex password generator.Īfter calling this function/cmdlet, you can then use the generated password in a step to set the password – given the method is supported by a PowerShell-cmdlet. You can find the New-RandomPassword cmdlet here: Instead of trying to reinivent the wheel i found a function/cmdlet by Tomas Deceuninck that worked really well. Sometimes you want to automatically generate passwords for new users – for example for accounts used for an isolated service, or to set temporary first time use passwords in AD for several hundred users at the same time. #2 – How to send e-mails to a list of users from a PowerShell script. #1 – Creating (semi) random passwords for users – and performing a set Password routine. This blog post will cover two subjects, step-by-step:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |