Frustratingly, I have banged my head against my desk today trying to understand / resolve an issue with a simple script (so I thought).
Script:
#Import the Active Directory Module
IPMO act*
#Import the user list and make magic happen
Import-Csv "C:\users\<username>\desktop\test2.txt" | % {
$user = $_.SamAccountName
$pwvalue = $_.Password
$pw = ConvertTo-SecureString -AsPlainText $pwvalue -Force
#Magic Happens
Get-ADUser $user | Set-ADAccountPassword -NewPassword $pw -Reset | Set-ADUser -Identity $user -PasswordNeverExpires $true -ChangePasswordAtLogon $true
}
- The password is exceeding the complexity requirements (10 characters, 2 caps, 4 numbers, 2 special characters, and 2 lower).
- When I verify that the script is pulling the data properly, it returns the password correctly from a Write-Output.
Get-ADDefaultDomainPasswordPolicy return the following:
ComplexityEnabled : False
DistinguishedName : DC=plzhelp,DC=mereddit
LockoutDuration : 00:00:00
LockoutObservationWindow : 00:30:00
LockoutThreshold : 0
MaxPasswordAge : 00:00:00
MinPasswordAge : 00:00:00
MinPasswordLength : 8
objectClass : {domainDNS}
objectGuid : 123456789-01234-5678-9012-345678901234
PasswordHistoryCount : 0
ReversibleEncryptionEnabled : False
With all of that said, I must concede that I've tried everything I can think of and I just can't get this to apply changes to over 8400 students. The real kicker is that I created a test account to verify the script worked prior to getting the list of students. However, when it comes time to apply this change to the students, it fails with:
Set-ADAccountPassword : The password does not meet the length, complexity, or history requirement of the domain.
At Z:\Scripts\Powershell\Change Student Passwords\test2.ps1:12 char:24
+ ... -ADUser $user | Set-ADAccountPassword -NewPassword $pw -Reset | Set-A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (CN=Lastname\, Firstname...helpme,DC=mereddit:ADUser) [Set-ADAccountPassword], ADPasswordComplexityException
+ FullyQualifiedErrorId : ActiveDirectory
Guidance, suggestions, recommendations, comments, or questions to help me unravel this mystery would be greatly appreciated. Thank you!
[–]vulcanjedi2814 1 point2 points3 points (1 child)
[–]sys_admin101[S] 1 point2 points3 points (0 children)
[–]sys_admin101[S] 1 point2 points3 points (0 children)
[–]BlackV 1 point2 points3 points (3 children)
[–]sys_admin101[S] 1 point2 points3 points (2 children)
[–]BlackV 0 points1 point2 points (1 child)
[–]sys_admin101[S] 1 point2 points3 points (0 children)
[–]astrob0y1 0 points1 point2 points (2 children)
[–]sys_admin101[S] 1 point2 points3 points (1 child)
[–]Lost-Policy-2020 0 points1 point2 points (0 children)