• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 51
  • Last Modified:

Rest AD ID password for multiple users

Below script looks fine I think... but getting error post execution. I have attached the error screenshot FYR...Thanks in advance


Import-Module activedirectory
$Resetpassword = Import-Csv C:\temp\inputfile.csv
 
foreach ($Account in $Resetpassword) {
    $Account.SAMAccountName
    $Account.Password
        Set-ADAccountPassword -Identity $Account.SAMAccountName -NewPassword
( ConvertTo-SecureString $Account.Password -AsPlainText -force)
}

Open in new window

Windows-Server-2008-R2-x64-2017-12-1.png
0
SAM IT
Asked:
SAM IT
  • 2
1 Solution
 
oBdACommented:
Remove the line break in the middle of the command (or use the backtick as line continuation character as last character in the line):
Import-Module activedirectory
$Resetpassword = Import-Csv C:\temp\inputfile.csv
 
foreach ($Account in $Resetpassword) {
    $Account.SAMAccountName
    $Account.Password
        Set-ADAccountPassword -Identity $Account.SAMAccountName -NewPassword (ConvertTo-SecureString $Account.Password -AsPlainText  -force)
} 

Open in new window

1
 
SAM ITAD windows Admin  Author Commented:
thanks a lot for quick response
0
 
SAM ITAD windows Admin  Author Commented:
thanks a lot for quick response
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now