# Script to bulk reset a list of user passwords in Active Directory # The list needs to be a list of user id's one per line. # import the AD module if (-not (Get-Module ActiveDirectory)){ Import-Module ActiveDirectory -ErrorAction Stop } $Password = Read-Host .AsSecureString "Enter the default password" $FileName = Read-Host "Enter Txt file name including the .txt extension (full path necessary if file not in same directory as script)" # get list of account names (1 per line) $list = Get-Content -Path $FileName # loop through the list ForEach ($u in $list) { if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$u)")) { Write-Host "Can't find $u" } else { $user = Get-ADUser -Identity $u $user | Set-ADAccountPassword -NewPassword $Password -Reset $user | Set-AdUser -ChangePasswordAtLogon $true Write-Host "changed password for $u" } }