Use Powershell to query account attributes in AD

Source: Internet
Author: User

If you want to know the account usage in the AD, such as when to create, the last logon time is the time, the last password change, and other information, these can be achieved by using PowerShell.

In PowerShell, Get-AdUser can query a lot of information. For more information, see the following article:


The following describes how to use PowerShell to query the creation time of all accounts in the specified OU \ SID \ last password change time \ last login time. The CMDlet is as follows:

Get-ADuser-searchbase'OU = User, OU = Compay1, DC = Domain, DC = COM'-Filter *-Properties * | Select-Object Name, SID, Created, PasswordLastSet, @ {n = "lastLogonDate"; e = {[datetime]: FromFileTime ($ _. lastLogonTimestamp) }}| Export-CSV Accountlist.csv-NoTypeInformation-Encoding UTF8

(Modify OU and domain information on your own)

Query the specified result to generate a. CSV file. Open it in Excel and perform necessary statistics and analysis. The results are as follows:

650) this. width = 650; "height =" 51 "title =" clip_image002 "style =" border: 0px currentcolor; display: inline; "alt =" clip_image002 "src =" "border =" 0 "/>

If you want to query all accounts in the entire AD, cancel-searchbase' in the middle'OU = User, OU = Compay1, DC = Domain, DC = COM.

This article is from the "big technology sharing" blog, please be sure to keep this source

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: 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.