PowerShellでOffice 365 に接続する方法

Office 365の管理のためにPowerShellで接続をする機会があるが、接続方法を忘れるのでまとめました。

この手順を行う事で下記のサービスに接続が可能です。

ブログにまとめていましたが、MSからもまとめページが出ていました。(2016/12/12追記)

Office 365への接続

管理者として Windows PowerShellを実行し下記コマンドを発行する。

$credential = Get-Credential
Import-Module MsOnline
Connect-MsolService -Credential $credential

Exchange Onlineへの接続

管理者として Windows PowerShellを実行し下記コマンドを発行する

初回のみ下記コマンドを実行

Set-ExecutionPolicy RemoteSigned

以下、通常手順

$credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber

SharePoint Onlineへの接続

管理者として Windows PowerShellを実行し下記コマンドを発行する

$credential = Get-Credential
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://<SharePoint Online管理サイトの URL > -credential $credential

※ SharePoint Online 管理サイトの URL について
ドメイン名のドメイン ホスト部分 + -admin.sharepoint.com となる。
ドメインが hogehoge.onmicrosoft.com であった場合は ドメインホストが hogehoge となり 管理サイトの URL は hogehoge -admin.sharepoint.com になる

Skype for Business Onlineへの接続

管理者として Windows PowerShellを実行し下記コマンドを発行する

$credential = Get-Credential
Import-Module SkypeOnlineConnector
$sfboSession = New-CsOnlineSession -Credential $credential
Import-PSSession $sfboSession

コンプライアンスセンターへの接続

管理者として Windows PowerShellを実行し下記コマンドを発行する

$credential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection
Import-PSSession $Session

各サービスへの接続するための前提条件について

◇ 動作環境
次の Windows の 64 ビット バージョンを使用可能とのことであったが、32ビット版でも動いていたりする。
・Windows 8.1 または Windows 8
・Windows Server 2012 R2 または Windows Server 2012
・Windows 7 Service Pack 1 (SP1)*
・Windows Server 2008 R2 SP1*

◇ Microsoft .NET Framework、Windows Management Framework のインストール
下記サイトより、Microsoft .NET Framework 4.5.xのインストール後に、Windows Management Framework 3.0または Windows Management Framework 4.0のインストールが必要です。

Title : .NET Framework のインストール
  URL : https://msdn.microsoft.com/library/5a4x27ek(VS.110).aspx

Title : Windows Management Framework 3.0
  URL : https://www.microsoft.com/en-us/download/details.aspx?id=34595

Title : Windows Management Framework 4.0
  URL : https://www.microsoft.com/ja-jp/download/details.aspx?id=40855

◇ 各サービス接続に必要なモジュールのインストール
Office 365、SharePoint Online、および Skype for Business Onlineに必要な以下のモジュールをインストールします。

Title : IT プロフェッショナル 用 Microsoft Online Services サインイン アシスタント RTW
  URL : https://www.microsoft.com/ja-jp/download/details.aspx?id=41950

Title : SharePoint Online Management Shell
  URL : https://www.microsoft.com/en-us/download/details.aspx?id=35588

Title : Skype for Business Online, Windows PowerShell Module
  URL : https://www.microsoft.com/en-us/download/details.aspx?id=39366

Title : Windows PowerShell 用 Windows Azure Active Directory モジュール (64 ビット バージョン)
  URL : http://go.microsoft.com/fwlink/p/?linkid=236297

コメント (0件)


くろねこ研究所
https://www.blackcat.xyz/article.php/BlogO365_PowerShell2O365