Connect to Azure AD
Azure AD PowerShell Modunle
You need install MSOnline module only once. In the next time, run to connect to Azure AD PowerShell.
##Connect to MSOnline
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;
Install-PackageProvider -Name NuGet -Force;
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted;
Install-Module -Name MSOnline;
Connect-MsolService;
Force password change for Office 365
Force a user to change his password on next login, without actually changing the password on his behalf
Set-MsolUserPassword -UserPrincipalName chris@leoguides.info `
-ForceChangePasswordOnly $true `
-ForceChangePassword $true
To force all users to change their password:
Get-MsolUser -All | Set-MsolUserPassword `
-ForceChangePasswordOnly $true `
-ForceChangePassword $true
To force a group of users to change their passwords:
Get-MsolUser -All | ? {$_.Department -eq "Sales"} |
Set-MsolUserPassword -ForceChangePasswordOnly $true -ForceChangePassword $true
Force change password of users from CSV file:
Import-Csv "C:\Temp\Users.csv" |
ForEach {Set-MsolUserPassword –UserPrincipalName $_.UserPrincipalName -ForceChangePasswordOnly $true -ForceChangePassword $true}
5/5 - (1 vote)