使用http连接到microsoft exchange_如何使用 PowerShell 连接 Office 365 服务

本文详细介绍了如何使用 PowerShell 连接Office 365的各项服务,包括Exchange Online、SharePoint Online、Office 365管理服务和Skype for Business Online。连接前需确保系统支持PowerShell,并安装相应模块。对于每个服务,文章提供了连接步骤和所需命令。
摘要由CSDN通过智能技术生成

适用于以下产品或服务0a8d1c1a750fa59bff8bfa7255e9dd4a.png 425aff174846ac961d846f957eeaba74.png e8e4c24147bde360191c3cdb951c50b1.png 63c479746b64161982cada8237bbb9fd.png

Office 365 管理员的日常管理中。使用 PowerShell 是除了Office365 管理中心外,最为高效的工具。这里将会介绍 PowerShell 连接到 Office365 服务的方法。

本篇摘要:

  • 前提条件

  • 连接到 Exchange Online

  • 连接到 SharePoint Online

  • 连接到 Office 365 管理服务

  • 连接到 Skype for Business Online

前提条件

为了能确保电脑可以正常使用 PowerShell,请进行下面的前期准备:

支持 PowerShell 连接Windows系统有(以下均为64 位系统):

Windows 10、Windows 8.1、Windows 8 或 Windows 7 Service Pack 1 (SP1)

Windows Server 2019、Windows Server 2016、WindowsServer 2012 R2、Windows Server 2012 或 Windows Server 2008 R2 SP1

初次使用PowerShell连接Office 365的各项服务时,需要先运行以下命令:

Set-ExecutionPolicy RemoteSigned

 连接到 Exchange online

1.      Exchange Online 的 Powershell Module 并不需要单独下载,具体的连接步骤如下:

$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell-LiveID/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session

2.      此时会弹出对话框提示您输入用户名和密码,这时您需要有效的、具备 Exchange Online 管理员权限的帐号,之后 PowerShell 会话会自动下载所需的 Exchange 模块。

d9577990e3d787474dbfc40eddf6e309.png

连接到 SharePoint Online

要通过 PowShell 连接 SharePoint Online 服务,您首先需要安装 SharePoint Online Management Shell,安装方式有两种:

方法一:直接下载安装:

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

方法二:我们可以通过 Nuget 在 PowerShell 中直接使用 Install-Module 命令来安装,命令如下:

Install-Module Microsoft.Online.SharePoint.PowerShell

此时您可能会在 PowerShell 上收到如下提示:

fe040be9e452840bf7ffe8a6882e197c.png

或者:

1b863f827fd9795d935987584903f4b4.png

无论哪种提示,都输入“Y”并按下回车即可

然后用以下命令连接到 SharePoint 管理中心:

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameCheckingConnect-SPOService -Url https://youro365domain-admin.sharepoint.cn -Credential 管理员账号

注意:youro365domain 为您 Office 365 租户的默认域名 如office365lab.partner.onmschina.cn,则输入 -Url https://office365lab-admin.sharepoint.cn;

管理员账号部分为拥有 SharePoint 管理员权限的帐号,在下一步弹窗中输入该帐号的密码。

在一些情况下,您可能还需要连接到 SharePoint PnP PowerShell,SharePoint PnP PowerShell 主要用户连接具体的SharePoint网站,而非整个 SharePoint 服务。安装 SharePointPnP PowerShell 模块的命令如下:

Install-Module SharePointPnPPowerShellOnline

同样的情况,如果PowerShell中出现任何提示,均输入“Y”,之后回车以继续。

之后您便可以通过以下命令连接到PowerShell PnP:

Import-Module SharePointPnPPowerShellOnlineConnect-PnPOnline –Url https://siteUrl –Credentials (Get-Credential)

其中 https://siteUrl 是您要连接的 SharePoint 站点的完整 URL,如以下示例:

https://office365lab.sharepoint.cn

https://office365lab-admin.sharepoint.cn

https://office365lab.sharepoint.cn/sites/demo

在弹出的窗口中输入该网站管理员的用户名和密码,即可连接。

有关 SharePoint Online PnP 的相关连接,您可参考:

https://docs.microsoft.com/zh-cn/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps

连接到 Office 365 管理服务

在使用 Office 365 管理服务的PowerShell之前,也需要安装其模块,安装方法也是两种:

方法一:安装 Microsoft Online Services 登陆小助手

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

6fa4bcdbec8e3f21af28dcff75d70dd1.png

方法二:在PowerShell中运行此指令:Install-Module MSOnline

在运行时,如果Powershell 出现任何提示,均输入“Y”并按下回车以继续。

  导入并连接Office 365服务

Import-Module msonlineConnect-MsolService -AzureEnvironment AzureChinaCloud

此时您会看到熟悉的 Office 365 现代模式凭据验证界面,直接输入您的管理员帐号密码即可。

 连接到 Skype for Business Online

1.     下载安装以下 Skype for Business Online 最新模块

Skype for Business Online, Windows PowerShell Module:

https://www.microsoft.com/en-sg/download/details.aspx?id=39366&751be11f-ede8-5a0c-058c-2ee190a24fa6=True  

2dac60b72c39b24fba8caa7477da2c1a.png

2.     执行以下命令,连接到 Skype for Business Online,需要输入管理员账号和密码

$cred = Get-CredentialImport-Module LyncOnlineConnector$cssess = New-CsOnlineSession -Credential $cred -Verbose  Import-PSSession $cssess

06b9cbca9a04c2120c70aea1e817c490.png

参考文档:

https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell   

欢迎大家关注我们的公众号,我们将持续进行技术文章的更新以及对 Office 365 技术的推广和普及。

90562c6412d37a4488990a0ec66e11ae.png

e5f27979ea29bf946a13b769d6a1f256.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值