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