LoginSignup
1
1

More than 5 years have passed since last update.

PowerShell で、SharePoint Online の web サイトの情報を書き出してみた

Last updated at Posted at 2017-05-01

目的

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 Web object
$Context.Load($Context.Web)
$Context.ExecuteQuery()

# Output 
Write-Host "Web Title : " $Context.Web.Title
Write-Host "Web Description : " $Context.Web.Description
Write-Host "Web Language : " $Context.Web.Language
Write-Host "Web WebTemplate : " $Context.Web.WebTemplate

# Dispose Context
$Context.Dispose()

参考

ClientContext クラス
https://msdn.microsoft.com/ja-jp/library/microsoft.sharepoint.client.clientcontext.aspx
ClientContext.Web プロパティ
https://msdn.microsoft.com/ja-jp/library/microsoft.sharepoint.client.clientcontext.web.aspx

1
1
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
1