1

When I reset a password in the Office 365 Admin portal, I have the option to send the new password in an email, without me even seeing the password first.

enter image description here

I know I can reset the password with

Set-MsolUserPassword

Can I also trigger the password email to an email address of my choice from Powershell - like in the UI? If yes, how?

0

One tweak to Mike111b's email:

You could simply use:

$Password = Set-MsolUserPassword -UserPrincipalName <UPN>

Then use the Send-MailMessage command.

The Set-MsolUserPassword command returns the password as an output so it can be saved to a variable.

-1

Yeah. Check out the Send-MailMessage cmdlet:

https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/send-mailmessage

Very basic implementation:

$UserPrincipalName = Read-Host "Enter the UserPrincipalName"
$Password = Read-Host "Enter the new password"

Set-MsolUserPassword -UserPrincipalName "$UserPrincipalName" -NewPassword "$Password"

Send-MailMessage -To "$UserPrincipalName" -From "ENTER YOUR EMAIL HERE" -Subject "Password Reset" -Body "I have reset your password.  Your new password is:`n`n$Password"

The authentication against the sender field is by default authenticated against the current user. If that doesn't work for you you can use the -Credential parameter.

I would also recommend randomizing each password. Whether that be from an online tool then pasted into PowerShell or done right in PowerShell it doesn't matter but I would make it a priority.

  • Why did I get a downvote? If I didn't answer your question accurately let me know and I can help you get to the right solution. – Michael Timmerman Dec 27 '16 at 23:25
  • The original question was how to do this "without me even seeing the password first.", so your solution using read-host isn't what they were looking for. – BlueCompute Jan 4 '17 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.