How to set AD password to expired / to be changed with PowerShell

Solution 1:

Get-ADUser -Identity $name | Set-ADUser -ChangePasswordAtLogon:$true 

Should do the trick.

Solution 2:

Office365 / ExchangeOnline / Exchange 2016 on Premises:

Connect-MsolService
$email = [email protected]
Set-MsolUser -UserPrincipalName $email |Set-MsolUserPassword -ForceChangePasswordOnly $true -ForceChangePassword $true