PowerShell Management Series (15) query ad accounts and Exchange accounts that have not been logged in for the last one months

Source: Internet
Author: User

-----provide ad\exchange\lync\sharepoint\crm\sc\o365 and other Microsoft product implementation and outsourcing, qq:185426445. Phone 18666943750

Today, I heard a friend in the group asking to inquire about an ad account that has not been logged in for the last 1 months, we can do this via PowerShell:

Requirement 1, query creation time of all accounts in OU \sid\ last modified password time \ Last Login time

PowerShell query Specifies the creation time for all accounts in the OU \sid\ last modified password time \ Last login time, can be completed by the following command: PS C:\Users\administrator. rightdo> get-aduser-searchbase ' dc=rightdo,dc=net '-filter *-properties * | Select-object Name,sid, created,passwordlastset,@{n= "Lastlogondate"; E={[datetime]::fromfiletime ($_. lastLogonTimestamp)}}

650) this.width=650; "Width=" 876 "height=" 641 "title=" QQ picture 20150131210400.png "style=" width:724px;height:585px; "alt= "Wkiom1tm2ritwpegaas6isjyt2s241.jpg" src= "Http://s3.51cto.com/wyfs02/M02/59/40/wKiom1TM2RiTWpeGAAS6ISjyT2s241.jpg"/>

Someone here has a question, Some people will ask, not have lastlogon this attribute, why also introduce lastLogonTimestamp this attribute?

Specific reasons, everyone to read this article, read it to know why, title: elaborate lastLogonTimestamp

Http://blogs.technet.com/b/apgceps/archive/2011/10/25/details-about-lastlogontimestamp.aspx

Requirements 2, Query the OU for all one months not logged in the AD account number,

PS C:\Users\administrator. rightdo> get-aduser-searchbase ' dc=rightdo,dc=net '-filter *-properties * | Select-object Name,sid, created,passwordlastset,@{n= "Lastlogondate"; E={[datetime]::fromfiletime ($_. lastLogonTimestamp)}} | where {$_.lastlogondate-lt (get-date). AddDays (-30)}

650) this.width=650; "Width=" 868 "height=" 540 "title=" QQ picture 20150131210400.png "style=" width:726px;height:470px; "alt= "Wkiol1tm1n6ywfcvaarsvhqm4m4755.jpg" src= "Http://s3.51cto.com/wyfs02/M01/59/3E/wKioL1TM1n6yWFCVAARsvHQm4M4755.jpg"/>

Requirement 3, Query the OU for all Exchange accounts that are not signed in for three months,

PS C:\Users\administrator. Rightdo> Add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
PS C:\Users\administrator. Rightdo> Get-mailbox-resultsize Unlimited | Get-mailboxstatistics | where {$_. Lastlogontime-lt (get-date). AddDays (-90)} | FT displayname,lastlogontime,lastloggedonuseraccount,servername

650) this.width=650; "Width=" 876 "height=" 514 "title=" QQ picture 20150131210400.png "style=" width:725px;height:461px; "alt= "Wkiol1tm2ezakvmlaai6d1jxrpq376.jpg" src= "Http://s3.51cto.com/wyfs02/M02/59/3E/wKioL1TM2EzAkvMLAAI6D1JxRpQ376.jpg"/>

This article is from the "Zhou Ping Microsoft Technology Exchange Platform" blog, please be sure to keep this source http://yuntcloud.blog.51cto.com/1173839/1610352

PowerShell Management Series (15) query ad accounts and Exchange accounts that have not been logged in for the last one months

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.