PowerShell Management Series (25) PowerShell operation or ad account and email information

Source: Internet
Author: User
Tags samaccountname

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

Sometimes we need to query many properties of the account, but need to get through different commands, a bit like SQL Server inside the multi-table connection query, such as querying all accounts of the AD account description, mailbox name, display name, email address, number of mailboxes, mailbox size, archive mailbox size, archive mailbox number.

AD Account Description---The description of the ad account, obtained by Get-aduser

mailbox name, display name, email address---corresponding user mailbox information, get

via Get-mailbox

Number of mailboxes, mailbox size ---Corresponding mailbox information, via command get-mailbox | Get-mailboxstatistics get

Archive mailbox size, archive mailbox number---corresponding archive mailbox information, via command get-mailbox-archive| Get-mailboxstatistics-archive Get

These properties are connected and queried by sAMAccountName this common attribute, as follows:


--------------------------------------------------------------------------------------------------------------- -----------------------------------

Cls

Add-pssnapin microsoft.exchange*

$mbxinfo =get-mailbox-resultsize Unlimited |%{$_. sAMAccountName}

$userlist = @ ()

foreach ($i in $mbxinfo)

{

$Description =get-aduser $i-properties * |%{$_. Description}

$user =get-mailbox $i

$userStatistics =get-mailbox $i | Get-mailboxstatistics

$userarchiveStatistics =get-mailbox $i-archive| Get-mailboxstatistics-archive

$userobject =new-object PsObject

$userobject | Add-member-membertype noteproperty-name AD Account Description-value $Description

$userobject | Add-member-membertype noteproperty-name mailbox name-value $user. Name

$userobject | Add-member-membertype noteproperty-name display name-value $user. DisplayName

$userobject | Add-member-membertype Noteproperty-name e-mail address-value $user. PrimarySmtpAddress

$userobject | Add-member-membertype noteproperty-name Number of mailboxes-value $userStatistics. ItemCount

$userobject | Add-member-membertype noteproperty-name Mailbox Size-value $userStatistics. totalitemsize

$userobject | Add-member-membertype noteproperty-name number of archive mailboxes-value $userarchiveStatistics. ItemCount

$userobject | Add-member-membertype noteproperty-name Archive Mailbox size-value $userarchiveStatistics. totalitemsize

$userlist + = $userobject

}

$userlist

$userlist |export-csv-path c:\userlist.csv-Encoding utf8-notypeinformation

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/76/03/wKioL1ZISK6SZ2A1AAGHhn5TYxg552.png "title=" QQ picture 20151115165015.png "alt=" Wkiol1zisk6sz2a1aaghhn5tyxg552.png "/>

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/1712918

PowerShell Management Series (25) PowerShell operation or AD account and mailbox information

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.