使用http连接到microsoft exchange_如何使用 PowerShell 连接 Office 365 服务
適用于以下產品或服務:???
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 $Session2.??????此時會彈出對話框提示您輸入用戶名和密碼,這時您需要有效的、具備 Exchange Online 管理員權限的帳號,之后 PowerShell 會話會自動下載所需的 Exchange 模塊。
連接到 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 上收到如下提示:
或者:
無論哪種提示,都輸入“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方法二:在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=True2. ????執行以下命令,連接到 Skype for Business Online,需要輸入管理員賬號和密碼
$cred = Get-CredentialImport-Module LyncOnlineConnector$cssess = New-CsOnlineSession -Credential $cred -Verbose Import-PSSession $cssess參考文檔:
https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell歡迎大家關注我們的公眾號,我們將持續進行技術文章的更新以及對 Office 365 技術的推廣和普及。
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的使用http连接到microsoft exchange_如何使用 PowerShell 连接 Office 365 服务的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 设计一款博弈类游戏的人机对战算法、策略_
- 下一篇: java运行效率优化_如何优化JAVA代