Windows PowerShell 管理 Office 365

來源:互聯網
上載者:User

Windows PowerShell 管理 Office 365

正如之前我們說的,通過O365管理中心、Exchange 系統管理中心、Lync管理中心SharePoint 管理中心能做的事情和能夠實現的需求是遠遠滿足不了客戶的時間需求的。可以使用用於 Windows PowerShell 的 Azure Active Directory 模組 cmdlet 執行 Azure AD 管理工作。而且還可以做到使用單個 Windows PowerShell 視窗串連和同時管理 Office 365、SharePoint、Exchange 和 Lync 管理工作。接下來讓我們一起來看看如何?的。
1. 先決條件
安裝Azure AD模組的系統要求
Windows 8.1、Windows 8、Windows 7、Windows Server 2012 R2、Windows Server 2012 或 Windows Server 2008 R2。

軟體要求及下載連結
 Microsoft Online Services 登入助手,下載連結如下:
http://www.microsoft.com/zh-cn/download/details.aspx?id=41950
 Microsoft Azure Active Directory 模組,下載連結如下:
http://go.microsoft.com/fwlink/p/?linkid=236297
 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左右;

運行程式Microsoft Online Services 登入助手(msoidcli_64),點擊”安裝“


安裝也是神速的,點擊”完成”

運行Microsoft Azure Active Directory 模組程式,點擊“Next”
vc29mdCBBenVyZSBBY3RpdmUgRGlyZWN0b3J5IMSjv+mzzNDy" border="0" src="http://www.bkjia.com/uploads/allimg/160409/040U34K0-3.png" title="運行Microsoft Azure Active Directory 模組程式" />

 


勾選”I Accept the terms in the License Terms”, 點擊“Next”

確認安裝路徑和是否產生案頭捷徑,點擊”Next”


點擊”Install”

完成安裝後,點擊”Finish”

 

運行LyncOnlinePowerShell 模組程式,勾選”I agree to the license terms and conditions“,點擊”Install“

安裝成功後點擊“Close“

 

運行SharePointOnlineManagementShell 模組安裝程式,勾選”I accept the terms in the license Agreement“,點擊”Install“



完成安裝後,點擊“Finish“

在控制台中可以確認已經安裝了以上四個組件了,

 

3. 串連到Office 365
以管理員身份運行此電腦上的Windows PowerShell;



運行命令”Get-Module”, 可看到目前只有2個模組的

運行命令” Import-Module MsOnline” 匯入O365模組, 在運行” Get-Module”, 可看到已經匯入多一個模組了;

運行“$credential = Get-Credential“,輸入O365管理員賬戶和密碼,建立O365憑據;

通過命令” Connect-MsolService -Credential $credential” 串連到O365, 確保沒有任何報錯和警告;

此時就可以管理O365了,可以運行一下幾個命令進行測試,如下:


4. 串連到 SharePoint Online
運行命令” Import-Module Microsoft.Online.SharePoint.PowerShell” 匯入模組,會收到警告提示有些命令可以沒有匯入,可以通過後加-Verbose再次匯入。

運行命令” Connect-SPOService -Urlhttps://itlight-admin.sharepoint.com -credential $credential” 串連至SharePoint Online.



註:以上是串連至全球版時用的命令,串連中國版O365 SharePoint Online時請使用以下命令:


Connect-SPOService -Urlhttps://itlight-admin.sharepoint.cn -credential $credential”

若要確認已串連,可在 Windows PowerShell 提示下鍵入命令” Get-SPOSite”,並按 ENTER 鍵

5. 串連至Lync Online
運行命令” Import-Module LyncOnlineConnector”匯入Lync模組,會發現報錯”在此系統上禁止運行指令碼“如:



剛開始我也遇到過這個問題,最後經過尋找Technet文檔和諮詢O365支援人員後發現,原因就是由於ExecutionPolicy的問題。更改預設策略為” RemoteSigned “後重新匯入模組即可。

運行以下命令載入Lync Online 管理指令碼
$lyncSession = New-CsOnlineSession -Credential $credential
Import-PSSession $lyncSession



6. 串連到 Exchange Online
運行以下命令載入Exchange Online管理指令碼
 中國版O365
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUrihttps://partner.outlook.cn/PowerShell-LiveID/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
 全球版O365
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $credential -Authentication "Basic" -AllowRedirection
Import-PSSession $exchangeSession

通過以上整個配置過程,我們已經實現了可以通過單一Windows PowerShell 實現統一管理Office 365、Exchange Online、Lync Online和SharePoint Online了。這樣以後的批量管理操作就非常方便了,特別是很多管理中心無法實現的工作。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.