目的,统计一个office365订阅下的exchange用户的登录情况。
一、使用远程PowerShell连接到Exchange Online
远程PowerShell可以让您从命令行管理Exchange Online设置。可以使用本地计算机的Windows PowerShell创建到Exchange Online的远程PowerShell会话。
过程很简单,只需要三个步骤:
1.输入Office365凭据
在计算机本地打开Windows PowerShell,并运行以下命令:
$UserCredential = Get-Credential
在”Windows PowerShell凭据请求”对话框中,输入您的Office 365用户名和密码,然后单击”确定”。
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
至此,已成功连接Exchange Online。
二、获取用户登录信息
Get-Mailbox|Get-MailboxStatistics