{"id":4907,"date":"2023-10-25T09:00:47","date_gmt":"2023-10-25T16:00:47","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=4907"},"modified":"2024-03-05T12:56:06","modified_gmt":"2024-03-05T20:56:06","slug":"how-to-set-an-individual-users-password-to-never-expire-in-azure-ad","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=4907","title":{"rendered":"How to Set an Individual User&#8217;s Password to Never Expire in Azure AD"},"content":{"rendered":"\n<p>This article explains how to set a password for an individual user to not expire. You have to complete these steps using PowerShell.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">Prerequisites<\/h2>\n\n\n\n<p>PowerShell 7 and later is the recommended PowerShell version for use with the Microsoft Graph PowerShell SDK on all platforms. There are no additional prerequisites to use the SDK with PowerShell 7 or later.<\/p>\n\n\n\n<p>The PowerShell script execution policy must be set to as below. <\/p>\n\n\n\n<p><strong><em><code>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser<\/code><\/em><\/strong><a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/microsoftgraph\/installation?view=graph-powershell-1.0#installation\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation\">Install Microsoft Graph<\/h2>\n\n\n\n<p>The Microsoft Graph PowerShell SDK comes in 2 modules, Microsoft.Graph and Microsoft.Graph.Beta, that you will install separately. These modules call the Microsoft Graph v1.0 and Microsoft Graph beta endpoints, respectively. You can install the 2 modules on the same PowerShell version.<\/p>\n\n\n\n<p>Using the&nbsp;<strong>Install-Module<\/strong>&nbsp;cmdlet is the preferred installation method for the Microsoft Graph PowerShell modules.<\/p>\n\n\n\n<p>Installing the main modules of the SDK, Microsoft.Graph and Microsoft.Graph.Beta, will install all 38 sub modules for each module. Consider only installing the necessary modules, including&nbsp;<code>Microsoft.Graph.Authentication<\/code>&nbsp;which is installed by default when you opt to install the sub modules individually. For a list of available Microsoft Graph modules, use&nbsp;<code>Find-Module Microsoft.Graph*<\/code>. Only cmdlets for the installed modules will be available for use.<\/p>\n\n\n\n<p>To install the v1 module of the SDK in PowerShell Core or Windows PowerShell, run the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Install-Module Microsoft.Graph -Scope CurrentUser<\/strong>\n<\/code><\/pre>\n\n\n\n<p>Optionally, you can change the scope of the installation using the&nbsp;<code>-Scope<\/code>&nbsp;parameter. This requires admin permissions.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Install-Module Microsoft.Graph -Scope AllUsers<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"verify-installation\">Verify installation<\/h3>\n\n\n\n<p>After the installation is completed, you can verify the installed version with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Get-InstalledModule Microsoft.Graph<\/strong>\n<\/code><\/pre>\n\n\n\n<p>The version in the output should match the latest version published on the PowerShell Gallery. Now you&#8217;re ready to use the SDK.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"updating-the-sdk\">Updating the SDK<\/h2>\n\n\n\n<p>You can update the SDK and all of its dependencies using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Update-Module Microsoft.Graph<\/strong><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-check-the-expiration-policy-for-a-password\">How to check the expiration policy for a password<\/h2>\n\n\n\n<p>Use the&nbsp;<code>Connect-MgGraph<\/code>&nbsp;command to sign in with the required scopes. You need to sign in with an admin account to consent to the required scopes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Connect-MgGraph -Scopes \"User.ReadWrite.All\",\"Group.ReadWrite.All\"<\/strong><\/code><\/pre>\n\n\n\n<p>The command prompts you to go to a web page to sign in using a device code. Once you&#8217;ve done that, the command indicates success with a&nbsp;<code>Welcome To Microsoft Graph!<\/code>&nbsp;message. You only need to sign in once per session.<\/p>\n\n\n\n<p>To see if a single user&#8217;s password is set to never expire, run the following cmdlet by using the UPN (for example,&nbsp;<em>user@contoso.onmicrosoft.com<\/em>) or the user ID of the user you want to check:<\/p>\n\n\n\n<p><strong>Get-MGuser -UserId &lt;userid&gt; -Property UserPrincipalName, PasswordPolicies | Select-Object UserPrincipalName,@{<br>N=&#8221;PasswordNeverExpires&#8221;;E={$_.PasswordPolicies -contains &#8220;DisablePasswordExpiration&#8221;}<br>}<\/strong><\/p>\n\n\n\n<p>To see the&nbsp;<strong>Password never expires<\/strong>&nbsp;setting for all users, run the following cmdlet:<\/p>\n\n\n\n<p><strong>Get-MGuser -All -Property UserPrincipalName, PasswordPolicies | Select-Object UserprincipalName,@{<br>N=&#8221;PasswordNeverExpires&#8221;;E={$_.PasswordPolicies -contains &#8220;DisablePasswordExpiration&#8221;}<br>}<\/strong><\/p>\n\n\n\n<p>To get a report of all the users with PasswordNeverExpires in CSV on the desktop of the current user with name&nbsp;<strong>ReportPasswordNeverExpires.csv<\/strong><\/p>\n\n\n\n<p><strong>Get-MGuser -All -Property UserPrincipalName, PasswordPolicies | Select-Object UserprincipalName,@{<br>N=&#8221;PasswordNeverExpires&#8221;;E={$_.PasswordPolicies -contains &#8220;DisablePasswordExpiration&#8221;}<br>} | ConvertTo-Csv -NoTypeInformation | Out-File $env:userprofile\\Desktop\\ReportPasswordNeverExpires.csv<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"set-a-password-to-never-expire\">Set a password to never expire<\/h2>\n\n\n\n<p>Run one of the following commands:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To set the password of one user so that the password expires, run the following cmdlet by using the UPN or the user ID of the user:<\/li>\n<\/ul>\n\n\n\n<p><strong>Update-MgUser -UserId &lt;userid&gt; -PasswordPolicies DisablePasswordExpiration<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To set the passwords of all users in the organization so that they expire, use the following cmdlet<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"257\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1-1024x257.png\" alt=\"\" class=\"wp-image-5052\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1-1024x257.png 1024w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1-300x75.png 300w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1-768x192.png 768w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1-1536x385.png 1536w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/03\/Untitled-1.png 1800w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Get-MGuser -All | Update-MgUser -PasswordPolicies DisablePasswordExpiration<\/strong><\/p>\n\n\n\n<p>Ref: <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/admin\/add-users\/set-password-to-never-expire?view=o365-worldwide\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/admin\/add-users\/set-password-to-never-expire?view=o365-worldwide<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to set a password for an individual user to not expire. You have to complete these steps using PowerShell. Prerequisites PowerShell 7 and later is the recommended PowerShell version for use with the Microsoft Graph PowerShell SDK on all platforms. There are no additional prerequisites to use the SDK with PowerShell <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=4907\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1249,10],"tags":[1700,1701],"class_list":["post-4907","post","type-post","status-publish","format-standard","hentry","category-azure-microsoft","category-microsoft","tag-password-never-expire-in-azure-ad","tag-set-password-to-never-expire-in-azure-ad"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/4907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4907"}],"version-history":[{"count":4,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/4907\/revisions"}],"predecessor-version":[{"id":5054,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/4907\/revisions\/5054"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}