Tuesday, May 21, 2019

Office 365 Password never expire change for Single user


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Get the office 365 credential
$AzureAdCred = Get-Credential
Connect-MsolService -Credential $AzureAdCred
Connect-AzureAD -Credential $AzureAdCred

# Below powershell command is used to set the PasswordNeverExpires to True.
Set-MsolUser -UserPrincipalName sanjiv@softpoc.com -PasswordNeverExpires $true

# Below powershell command is used to Get the PasswordNeverExpires status for individual user.
Get-AzureADUser -ObjectId sanjiv@softpoc.com | Select-Object UserprincipalName,@{

    N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}

 }

No comments:

Post a Comment

HTML

Script:

JS