目的
SharePoint Online では、Client Side Object Model(CSOM)を使って、
色々な情報を抜き出したり、書き込んだりすることができる。
これを使うと、簡単に管理作業が出来るので、これから色々なスクリプトを書いてみる。
CSOMに関することは、サポートチームのblogで、
https://blogs.technet.microsoft.com/sharepoint_support/2014/10/19/sharepoint-online-powershell/
事前準備
以下のインストール
- PowerShell Ver 3.0 以上
- SharePoint Server 2013 Client Components SDK
( https://www.microsoft.com/en-us/download/details.aspx?id=42038 )
サンプル
設定する項目は、以下の二か所
\$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
要望
他のプロパティも、そのうち追加しますが、これを見たいというものがあれば、コメントにお願いします。