PowerShell code _powershell to bulk modify AD user Password properties

Source: Internet
Author: User
Tags foreach

Requirements: A very common requirement is to change the password for AD users, but the problem is that the amount is too large. So I wrote a script.

CLS
$pass = convertto-securestring-asplaintext 12333333344.abc-force
 
import-csv-path d:\pp.csv | foreach {
  get-aduser-identity $_.name| Set-adaccountpassword-reset-newpassword $pass
get-aduser-identity $_.name| Set-aduser-changepasswordatlogon $false
$_.name
}

This script runs, requires a local module with Active Directory, does not require manual import, and is mounted automatically.
The above script changes the password and also sets whether the next login needs to change the password.
In a foreach loop, you can add multiple actions for user names, such as modifying attributes, account expiration, and so on.

The content format of the Pp.csv file that needs to be used is as follows

Name
Wangerxiao
Dongcunrui

This article comes from "Nine uncle-Microsoft Private Cloud" blog

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.