はじめに
PowerShellでOffice 365各種サービスに接続する際の手順メモ。
一旦はOffice 365とExOだけ。ほかのサービスはそのうち。
前提
- Windows 10(Win8.1以前だとサインインアシスタントが別途必要だったりする)
- PowerShellの実行ポリシーが
RemoteSigned
以上に緩和されている(されていなければSet-ExecutionPolicy RemoteSigned
を実行しておく)
Office 365
モジュールインストール(初回のみ)
Install-Module MSOnline
接続
Connect-MsolService
Exchange Online(接続時に多要素認証の利用なし)
モジュールインストール & 接続
Import-PSSession (New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential (Get-Credential) -Authentication Basic -AllowRedirection)
Exchange Online(接続時に多要素認証の利用あり)
モジュールインストール (初回のみ)
多要素認証を使用して Exchange Online PowerShell に接続するを参考に「Exchange Online リモート PowerShell モジュール」をインストールする。
接続
Connect-EXOPSSession
参考
https://docs.microsoft.com/ja-jp/office365/enterprise/powershell/connect-to-office-365-powershell
https://docs.microsoft.com/ja-jp/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell
https://docs.microsoft.com/ja-jp/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell
以上