LoginSignup
1
4

More than 5 years have passed since last update.

PowerShell で、SharePoint Online の リストの一覧を書き出してみた

Last updated at Posted at 2017-05-02

目的

SharePoint Online では、Client Side Object Model(CSOM)を使って、
色々な情報を抜き出したり、書き込んだりすることができる。
これを使うと、簡単に管理作業が出来るので、これから色々なスクリプトを書いてみる。

CSOMに関することは、サポートチームのblogで、
https://blogs.technet.microsoft.com/sharepoint_support/2014/10/19/sharepoint-online-powershell/

事前準備

以下のインストール

サンプル

設定する項目は、以下の二か所

\$SiteCollectionUrl :サイトコレクションのURL
\$Account :管理者権限のアカウント

 # Read CSOM
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") | Out-Null

# SiteCollection URL 
$SiteCollectionUrl = "https://tenant-name.sharepoint.com" 
# $SiteCollectionUrl = "https://tenant-name.sharepoint.com/sites/subsite" 

# Account
$Account = "administratorsName@tenant-name.onmicrosoft.com" 
$SecurePassword = Read-Host -Prompt "Enter Your Password." -AsSecureString

# Create Credential
$Credential = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Account, $SecurePassword) 

# Create Context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteCollectionUrl)
$Context.Credentials = $credential

# Create List object
$Context.Load($Context.Web.lists) 
$Context.ExecuteQuery()

# Output 
foreach($objList in $Context.Web.lists)
{
    Write-Host "list Title : " $objList.Title
}

# Dispose Context
$Context.Dispose()

参考

List メンバー
https://msdn.microsoft.com/ja-jp/library/microsoft.sharepoint.client.list_members.aspx

要望

他のプロパティも、そのうち追加しますが、これを見たいというものがあれば、コメントにお願いします。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4