使用powershell统计office365中exchange用户登录情况

目的,统计一个office365订阅下的exchange用户的登录情况。

一、使用远程PowerShell连接到Exchange Online

远程PowerShell可以让您从命令行管理Exchange Online设置。可以使用本地计算机的Windows PowerShell创建到Exchange Online的远程PowerShell会话。

过程很简单,只需要三个步骤:

1.输入Office365凭据

在计算机本地打开Windows PowerShell,并运行以下命令:

$UserCredential = Get-Credential

在”Windows PowerShell凭据请求”对话框中,输入您的Office 365用户名和密码,然后单击”确定”。

使用powershell统计office365中exchange用户登录情况_第1张图片

2.提供所需的连接设置

运行以下命令:

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.of    
fice365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection

注意:如果您是由世纪互联运营的中国Office365客户,请为ConnectionUri参数使用以下值:https://partner.outlook.cn/PowerShell.

3.将Exchange Online cmdlet导入本地Windows PowerShell会话以供使用

Import-PSSession $Session

image

至此,已成功连接Exchange Online。

二、获取用户登录信息

Get-Mailbox|Get-MailboxStatistics

使用powershell统计office365中exchange用户登录情况_第2张图片

转载于:https://my.oschina.net/forlinux/blog/528871

你可能感兴趣的:(使用powershell统计office365中exchange用户登录情况)