Office 365 グループ機能で作成した サイトを列挙する方法

こんにちは SharePoint サポートの森 健吾 (kenmori) です。

Office 365 グループ機能を使うことで、グループ単位で サイト コレクションを作成できます。これらのサイト コレクションは、各テナントで使用できる容量を消費します。

2018.3.23 追記 : 現在の SharePoint Online 管理シェルでは、Get-SPOSite でこれらのサイトを確認できるため、本投稿のサンプルを使用する必要はありません。

 Get-SPOSite | where Template -like "GROUP#*"

ただし、Office 365 グループを取得するコードは役立つシナリオがあるかもしれませんので、下記の記事はのこしたままとします。

 

以下に、Office 365 グループ機能で作成されたサイト コレクションの情報を取得する PowerShell サンプル コードをご紹介します。

 

手順

1. 以下の内容をテキスト エディタに貼り付けます。

 param(
  $AdminUrl,
  $UserName,
  $Password,
  $Detail
)
$sstr = ConvertTo-SecureString -string $Password -AsPlainText -Force
$spocred = New-Object System.Management.Automation.PSCredential($UserName, $sstr)
Connect-SPOService -Url $AdminUrl -Credential $spocred
$exosession = New-PSSession -ConfigurationName Microsoft.Exchange -Credential $spocred -Authentication Basic -ConnectionUri https://ps.outlook.com/powershell -AllowRedirection
$temp = Import-PSSession $exosession -AllowClobber -DisableNameChecking
$groupsites = (Get-UnifiedGroup).SharepointSiteUrl
foreach ($groupsite in $groupsites)
{
  if ($groupsite)
  {
    if ($Detail)
    {
      Get-SPOSite $groupsite | fl
    }
    else
    {
      Get-SPOSite $groupsite
    }
  }
}
Remove-PSSession $exosession

2. ファイル名を get-groupspersonalsite.ps1 などとして保存します。

3. 引数を指定して実行します。

(概要モードで実行)
PS> .\get-groupspersonalsite.ps1 -AdminUrl https://tenant-admin.sharepoint.com/ -UserName admin@tenant.onmicrosoft.com -Password PASSWORD

(詳細モードで実行)
PS> .\get-groupspersonalsite.ps1 -AdminUrl https://tenant-admin.sharepoint.com/ -UserName admin@tenant.onmicrosoft.com -Password PASSWORD -Detail $true

 

類似のシナリオ
OneDrive for Business サイト (個人用サイト) を列挙するスクリプトは以下に紹介されておりますので、ご参考にしてください。

タイトル :  OneDrive for Business のサイト コレクションの一覧を表示する方法
アドレス : https://technet.microsoft.com/ja-jp/library/dn911464.aspx

 

参考情報
以下に参考情報を記載いたします。

タイトル : Office 365 グループについて
アドレス : https://support.office.com/ja-jp/article/b565caa1-5c40-40ef-9915-60fdb2d97fa2

タイトル : Get-UnifiedGroup
アドレス : https://technet.microsoft.com/ja-jp/library/mt238272(v=exchg.160).aspx

タイトル : SharePoint Online に対して PowerShell を使用する方法
アドレス : https://blogs.technet.microsoft.com/sharepoint_support/2014/10/19/sharepoint-online-powershell/

今回の投稿は以上となります。