The PowerShell scripts given below can be used to manage the default password policy for an Active Directory domain. ADSelfService Plus, the Active Directory self-service password management and single sign-on solution, provides advanced password policy settings that can be applied for hybrid Active Directory. The following is a comparison between group policy object (GPO)-based domain password policy settings available in Windows Active Directory and ADSelfService Plus:
Set-ADDefaultDomainPasswordPolicy
[-WhatIf]
[-Confirm]
[-AuthType <ADAuthType>]
[-ComplexityEnabled <Boolean>]
[-Credential <PSCredential>]
[-Identity] <ADDefaultDomainPasswordPolicy>
[-LockoutDuration <TimeSpan>]
[-LockoutObservationWindow <TimeSpan>]
[-LockoutThreshold <Int32>]
[-MaxPasswordAge <TimeSpan>]
[-MinPasswordAge <TimeSpan>]
[-MinPasswordLength <Int32>]
[-PassThru]
[-PasswordHistoryCount <Int32>]
[-ReversibleEncryptionEnabled <Boolean>]
[-Server <String>]
[<CommonParameters>]
Get-ADDefaultDomainPasswordPolicy
[-AuthType <ADAuthType>]
[-Credential <PSCredential>]
[[-Current] <ADCurrentDomainType>]
[-Server <String>]
[<CommonParameters>]
Check the current domain password policy settings using the script below. This displays the password length, complexity, and lockout settings.
Get-ADDefaultDomainPasswordPolicySet a strong password policy by running the script below. This policy will require a minimum of 12 characters, enforce complex passwords, and lock accounts after five failed attempts.
Set-ADDefaultDomainPasswordPolicy -MinPasswordLength 12 -ComplexityEnabled $true -LockoutThreshold 5For different policies based on user roles, run the script below. This enforces stricter rules for admin accounts.
New-ADFineGrainedPasswordPolicy -Name "AdminsPolicy" -Precedence 1 -MinPasswordLength 15 -ComplexityEnabled $true -LockoutThreshold 3Apply the policy to a specific group. This ensures that only admins follow this stricter policy.
Add-ADFineGrainedPasswordPolicySubject -Identity "AdminsPolicy" -Subjects "Domain Admins"Check the current password policy by running the script below. This returns the domain's default password settings.
Get-ADDefaultDomainPasswordPolicyRun the script below to enforce a stronger password policy. This sets 12-character complex passwords with lockout after five failed attempts.
Set-ADDefaultDomainPasswordPolicy -MinPasswordLength 12 -ComplexityEnabled $true -LockoutThreshold 5Yes, this can be done using fine-grained password policies (FGPP).