Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台







    正如之前我们说的,通过 O365 管理中心、Exchange 管理中心、Lync 管理中 心 SharePoint 管理中心能做的事情和能够实现的需求是远远满足不了客户的时 间需求的。可以使用用于 Windows PowerShell 的 Azure Active Directory 模块 cmdlet 执行 Azure AD 管理任务。而且还可以做到使用单个 Windows PowerShell 窗口连接和同时管理 Office 365、SharePoint、Exchange 和 Lync 管理任务。接下 来让我们一起来看看如何实现的。 


  1. 先决条件

  • 安装 Azure AD 模块的系统要求

    Windows 10、Windows 8.1、Windows 8、Windows 7、Windows Server 2016、Windows Server 2012 R2、Windows Server 2012 或 Windows Server 2008 R2。

  •  软件要求及下载链接 

    Microsoft Online Services 登录助手,下载链接如下:

https://www.microsoft.com/zh-cn/download/details.aspx?id=41950 

    Microsoft Azure Active Directory 模块,下载链接如下: 

https://connect.microsoft.com/site1164/Downloads/DownloadDetails.aspx?DownloadID=59185 

    Windows PowerShell Module for Lync Online,下载链接如下: 

http://www.microsoft.com/en-us/download/details.aspx?id=39366 

    SharePoint Online Management Shell, 下载链接如下: 

http://www.microsoft.com/en-us/download/details.aspx?id=35588 


注:1. 自 2014 年 10 月 20 日起,用于 Windows PowerShell 的 Azure 

Active Directory 模块(32 位版本)将正式停用; 

2. Exchange Online 是没有独立的模块的,已经包含在Azure AD中; 

3. 必须先安装Microsoft Online Services 登录助手才能安装其他组件


2.安装必备组件 

  • 根据上述提供的链接下载这个四个安装程序,加起来也就只有15M左右; 

Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  •  运行程序 Microsoft Online Services 登录助手(msoidcli_64),点击”安装“ 

                             Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 安装也是神速的,点击”完成” 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 运行 Microsoft Azure Active Directory 模块程序,点击“Next” 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 勾选”I Accept the terms in the License Terms”, 点击“Next” 

                           Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 确认安装路径和是否生成桌面快捷方式,点击”Next” 

                           Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 点击”Install” 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 完成安装后,点击”Finish” 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 运行 LyncOnlinePowerShell 模块程序,勾选”I agree to the license terms and conditions“,点击”Install“ 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 安装成功后点击“Close“ 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 运行 SharePointOnlineManagementShell 模块安装程序,勾选”I accept the terms in the license Agreement“,点击”Install“ 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 完成安装后,点击“Finish“ 

                            Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 在控制面板中可以确认已经安装了以上四个组件了,如图: 

                         Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

 3. 连接到 Office 365

  • 已管理员身份运行Windows PowerShell

  • 运行“Get-Module”可以看到目前有几个模块。

        Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 运行命令” Import-Module MsOnline” 导入 O365 模块, 在运行” Get-Module”, 可看到已经导入多一个模块了; 

        Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 运行“$credential = Get-Credential“,输入 O365 管理员账户和密码,创建 O365 凭据; 

        Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 通过命令” Connect-MsolService -Credential $credential” 连接到 O365, 确保没 有任何报错和警告;

        Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  • 此时就可以管理 O365 了,可以运行一下几个命令进行测试,如下: 

        Office 365 系列之十一:使用 Windows PowerShell 管理 O365 平台

  

 

 通过以上整个配置过程,我们已经实现了可以通过单一 Windows PowerShell 实现统一管理 Office 365 了。这样以后的批量管理操作就非常方便了,特别是很多管理中心无法实现的工作。 




本文转自 Juck_Zhang  51CTO博客,原文链接:http://blog.51cto.com/itsoul/2044165