PowerShell daily AD Management-2

Source: Internet
Author: User

The previous chapter wrote about querying the OU and OU for the user's information, today is writing how to modify the user's property values, of course, not a single modification, using PowerShell batch modification, even if you want to modify a domain user that there is no problem, such as you in order to modify the user's password in an OU, Do you want to change it manually?
Need to set the user in the OU to change the password at the next logon or the password never expires, do you also want to check all user Point user properties? If the front can be done with the image interface, that to statistics for nearly one months without login users, this can also image, so we can use the command to do these things easily! command is not posted out, in fact, according to a convenient understanding and memory, detailed use of the method on the previous chapter has OH

1. Come up first hot, the OU in the User Manager is set to administrator, the first step is to query Aduser, and then view all, filter out the user in the OU, the pipe after the modification of the User Manager attribute, enter the manager name on it (this is also possible to figure Like the interface full point property set)

650) this.width=650; "title=" sets the User Manager in the OU. PNG "src=" Http://s4.51cto.com/wyfs02/M01/82/99/wKioL1dcy9iBbAFAAABMMg_ D2oe898.png "alt=" Wkiol1dcy9ibbafaaabmmg_d2oe898.png "/>



2. Almost missed it, query the number of users in the OU the most common, curly braces enclose all the commands, and then end. Count. Query which ou,searchbase to write which OU, look at the number of company owners to write the largest OU, nonsense a bit more, let everyone less mistakes.

My OU in the figure is the parent OU (largest)

(Get-adorganizationalunit-filter *). Count, this is the query for the number of OUs, the command is similar

650) this.width=650; "title=" Statistics domain number of users. PNG "src=" Http://s4.51cto.com/wyfs02/M00/82/9A/wKiom1dczC6Sth_uAAAHRJP9IRU779.png "alt=" wkiom1dczc6sth_ Uaaahrjp9iru779.png "/>



3. Many users in the domain are not logged in, most of the passwords expire, so you want to re-bulk modify the password of the next domain user

650) this.width=650; "title=" Sets all user passwords. PNG "src=" Http://s3.51cto.com/wyfs02/M01/82/9C/wKiom1dc0SiDsfK0AAAgnPTfAqU314.png "alt=" Wkiom1dc0sidsfk0aaagnptfaqu314.png "/>



4. Users to change their passwords when they log in again

650) this.width=650; "title=" sets the user's next logon to modify the password. PNG "style=" Float:none; "src=" Http://s2.51cto.com/wyfs02/M02/82/9C/wKiom1dc0hqBmaY0AAAcZfvUHOo599.png "alt=" Wkiom1dc0hqbmay0aaaczfvuhoo599.png "/>

650) this.width=650; "title=" Change Password the next time you log in. PNG "style=" Float:none; "src=" Http://s2.51cto.com/wyfs02/M00/82/9A/wKioL1dc0yiypxgeAABlqgtXJb8612.png "alt=" Wkiol1dc0yiypxgeaablqgtxjb8612.png "/>



5. Then the previous command modifies the property value to Passwordneverexpires, and vice versa, change $ true to $ false

If you set the password to never expire, it is wrong to continue to set the password change at the next logon, and there will be conflicting

650) this.width=650; "title=" Set User Password never expires. PNG "style=" Float:none; "src=" Http://s4.51cto.com/wyfs02/M01/82/9C/wKiom1dc0t6g7XFcAAAbvM9AgvI846.png "alt=" Wkiom1dc0t6g7xfcaaabvm9agvi846.png "/>

650) this.width=650; "title=" Password never expires. PNG "style=" Float:none; "src=" Http://s4.51cto.com/wyfs02/M00/82/9C/wKiom1dc0t7Cq4a9AABlyRhthsQ369.png "alt=" Wkiom1dc0t7cq4a9aablyrhthsq369.png "/>



6. To get the user's last logon time is to invoke all of the user's properties and then display the name and lastlogondate value.

Last followed by wildcards is a reminder of the flexibility to apply wildcards

650) this.width=650; "title=" gets the user's last logon time. PNG "src=" Http://s1.51cto.com/wyfs02/M02/82/9A/wKioL1dc1RrCQIr1AAApsREuEtE721.png "alt=" Wkiol1dc1rrcqir1aaapsreuete721.png "/>


7. See which users have changed passwords in the last one months, display name and modification time

See which users have changed passwords in the last one months, display names and modification times, from today June 12, one months ago is May 12, so use greater than number to determine

Attach operator

-eq: Equals
-ne: Not equal to
-GT: Greater Than
-ge: greater than or equal to
-LT: Less than
-le: Less than or equal to
-contains: Contains
-notcontains: not included

650) this.width=650; "Title=" The user who modified the password today. PNG "src=" Http://s2.51cto.com/wyfs02/M00/82/9B/wKioL1dc19ugJm60AAAsu8PgkwY486.png "alt=" Wkiol1dc19ugjm60aaasu8pgkwy486.png "/>



If there are other problems with small partners, you can leave a message to discuss with each other!





This article is from the "Sameold" blog, make sure to keep this source http://1163739403.blog.51cto.com/11663406/1788165

PowerShell daily AD Management-2

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.