温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-08-23 19:15:50 来源:网络 阅读:835 作者:rp722 栏目:系统运维

公司用的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:\Script\maillist.csv -NoTypeInformation

#office365管理员账号
$pw=ConvertTo-SecureString -String "Password" -AsPlainText -force
$cre= New-Object System.Management.Automation.PSCredential("xx@domain.com",$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:\Script\maillist.csv| %{
$id=$_.mail
$size=Get-MailboxStatistics $id | select TotalItemSize

[pscustomobject]@{

email=$id
Size=$size
}

}|Export-Csv -Path C:\Script\size.csv -NoTypeInformation

#断开会话
Remove-PSSession $Session
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI