日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Powershell管理系列(二十五)PowerShell操作之获取AD账号及邮箱信息

發(fā)布時(shí)間:2025/4/16 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Powershell管理系列(二十五)PowerShell操作之获取AD账号及邮箱信息 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

-----提供AD\Exchange\Lync\Sharepoint\CRM\SC\O365等微軟產(chǎn)品實(shí)施及外包,QQ:185426445.電話18666943750

有時(shí)候我們需要查詢賬號(hào)的很多屬性,但是需要通過不同的命令去獲取,有點(diǎn)類似SQL Server里面的多表連接查詢,比如查詢所有賬號(hào)的ad賬號(hào)描述,郵箱名,顯示名,郵箱地址,郵箱數(shù)目,郵箱大小,存檔郵箱大小,存檔郵箱數(shù)目。

ad賬號(hào)描述---對(duì)應(yīng)AD賬號(hào)的描述信息,通過Get-adUser 獲取

郵箱名,顯示名,郵箱地址---對(duì)應(yīng)用戶郵箱信息,通過get-mailbox獲取

郵箱數(shù)目,郵箱大小---對(duì)應(yīng)郵箱信息,通過命令get-mailbox |Get-MailboxStatistics 獲取

存檔郵箱大小,存檔郵箱數(shù)目---對(duì)應(yīng)存檔郵箱信息,通過命令get-mailbox -Archive|Get-MailboxStatistics -Archive獲取

這些屬性通過SamAccountName這個(gè)共同的屬性連接和查詢,具體操作如下:


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

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賬號(hào)描述 ? ? ?-value $Description

$userobject | Add-Member -membertype noteproperty -Name 郵箱名 ? ? ? ? ?-Value $user.Name

$userobject | Add-Member -membertype noteproperty -Name 顯示名 ? ? ? ? ?-Value $user.DisplayName?

$userobject | Add-Member -membertype noteproperty -Name 郵箱地址 ? ? ? ?-Value $user.PrimarySmtpAddress

$userobject | Add-Member -membertype noteproperty -Name 郵箱數(shù)目 ? ? ? ?-Value $userStatistics.ItemCount

$userobject | Add-Member -membertype noteproperty -Name 郵箱大小 ? ? ? ?-Value $userStatistics.TotalItemSize

$userobject | Add-Member -membertype noteproperty -Name 存檔郵箱數(shù)目 ? ?-Value $userarchiveStatistics.ItemCount

$userobject | Add-Member -membertype noteproperty -Name 存檔郵箱大小 ? ?-Value $userarchiveStatistics.TotalItemSize

$userlist+=$userobject

}?

$userlist

$userlist|export-csv -Path c:\userlist.csv -Encoding utf8 -NoTypeInformation



總結(jié)

以上是生活随笔為你收集整理的Powershell管理系列(二十五)PowerShell操作之获取AD账号及邮箱信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。