We will see here how to force users to change their Office 365 password.
First we will see how to do it for one account then we will see how to do it for multiple accounts.
We will need MSOnline module to connect to Office 365 with PowerShell.
PS C:\> Install-Module -Name MSOnline
PS C:\> Connect-MsolService
PS C:\> Set-MsolUserPassword -UserPrincipalName user@shebangthedolphins.net -NewPassword NewPassw0rd -ForceChangePassword $False
PS C:\> Set-MsolUserPassword -UserPrincipalName user@shebangthedolphins.net -ForceChangePasswordOnly $true -ForceChangePassword $true
PS C:\> Get-MsolUser -SearchString cartman
PS C:\> Get-MsolUser | Where-Object {$_.islicensed} | Select-Object UserPrincipalName | Sort-Object UserPrincipalName > c:\users.txt
If we want to force a large number of users to change their password we can use a powershell script.
########################### # author : shebangthedolphins.net # version : 1.0 # date : 2021.04 # role : force users from a text file to change their Office 365 password # other : create a C:\users.txt file where you will put users # updates : # - 1.0 (2021/03) : First Version Connect-MsolService $file = "C:\users.txt" ForEach ($line in (Get-Content -Path $file)) { Write-Host "Set-MsolUserPassword -UserPrincipalName" $line.Replace(' ','') "-ForceChangePasswordOnly $true -ForceChangePassword $true" Set-MsolUserPassword -UserPrincipalName $line.Replace(' ','') -ForceChangePasswordOnly $true -ForceChangePassword $true }
Contact :