加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

powershell 批量获取office365用户邮箱使用容量

发布时间:2020-12-15 21:29:16 所属栏目:安全 来源:网络整理
导读:公司用的office365的Excahnge Online,云端默认有50G容量。 2,3年下来,发现销售或者售后的邮箱容量会很快就要到达极限了,为了方便查看那些用户快到使用极限,那肯定要用powershell. 附:官方文档,如何用powershell连接到Exchange Online https://docs.mic
公司用的office365的Excahnge Online,云端默认有50G容量。

2,3年下来,发现销售或者售后的邮箱容量会很快就要到达极限了,为了方便查看那些用户快到使用极限,那肯定要用powershell.

附:官方文档,如何用powershell连接到Exchange Online
https://docs.microsoft.com/zh-cn/powershell/exchange/exchange-eop/connect-to-exchange-online-protection-powershell?view=exchange-ps

#获取ECH用户邮箱到csv,再AD内执行
Get-ADUser -SearchBase ‘OU=users,DC=domain,DC=com‘ -Filter {(mail -ne "null") -and (Enabled -eq "true")} -Properties mail | Select-Object mail | export-csv -Path C:Scriptmaillist.csv -NoTypeInformation

#office365管理员账号
$pw=ConvertTo-SecureString -String "Password" -AsPlainText -force
$cre= New-Object System.Management.Automation.PSCredential("[email?protected]",$pw)
#链接office365
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cre -Authentication Basic -AllowRedirection
#创建会话
Import-PSSession $Session -DisableNameChecking

#导入email地址 并输出其邮件容量
Import-Csv C:Scriptmaillist.csv| %{
$id=$_.mail
$size=Get-MailboxStatistics $id | select TotalItemSize

[pscustomobject]@{

email=$id
Size=$size
}

}|Export-Csv -Path C:Scriptsize.csv -NoTypeInformation

#断开会话
Remove-PSSession $Session

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读