locked
PowerShell script to force a list of Active Directory domain user to change password at Next Logon RRS feed

  • Question

  • Hi,

    I am trying to force a list of Active directory domain user to change their login password during their next logon because of some reason, can anyone please help me out..!


    Mohammed...

    Saturday, December 9, 2017 12:37 PM

Answers

  • To do this in bulk for a list of users, a lot depends on the list. It could be a text file, csv, spreadsheet, members of a group, or all users in an OU. If you have a comma delimited file with a header line that defines the field "sAMAccountName" (which uniquely identifies the users in the domain), you can use the Import-Csv cmdlet to import the lines, then use a ForEach to loop through the users and operate on each. For example:

    Import-Csv c:\users.csv | ForEach
    {
        Set-ADUser -Identity $_.sAMAccountName -ChangePasswordAtLogon $True
    }
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by Mohammed_Jaz Monday, December 11, 2017 3:06 AM
    Monday, December 11, 2017 12:24 AM

All replies

  • Use the Set-ADUser cmdlet and assign $True to the ChangePasswordAtLogon property. Check the help for Set-ADUser.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Saturday, December 9, 2017 1:15 PM
  • Sunday, December 10, 2017 8:40 PM
  • To do this in bulk for a list of users, a lot depends on the list. It could be a text file, csv, spreadsheet, members of a group, or all users in an OU. If you have a comma delimited file with a header line that defines the field "sAMAccountName" (which uniquely identifies the users in the domain), you can use the Import-Csv cmdlet to import the lines, then use a ForEach to loop through the users and operate on each. For example:

    Import-Csv c:\users.csv | ForEach
    {
        Set-ADUser -Identity $_.sAMAccountName -ChangePasswordAtLogon $True
    }
    


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Marked as answer by Mohammed_Jaz Monday, December 11, 2017 3:06 AM
    Monday, December 11, 2017 12:24 AM
  • Thanks for all your replies guys...Thanks you @Richard Mueller, it helped me to solve...!

    Mohammed...

    Monday, December 11, 2017 3:07 AM
  • How to force all users to change their Active Directory password at next logon:
    http://expert-advice.org/active-directory/force-users-change-active-directory-password-next-logon/
    Monday, December 11, 2017 6:50 AM