株式会社ヴァンデミックシステム

Blog

<スポンサーリンク>

SharePointOnlineのPowershellは2つあります。
1つ目は、SharePointOnline管理シェルで大まかな操作が可能。
ユーザー追加、サイトコレクションの追加などなど。
2つ目は、CSOM(クライアントサイドオブジェクトモデル)と呼ばれる、SharePointサーバの外部から事項できるAPIが用意されていて、それを実行する。
ドキュメントライブラリの操作などはこれを使わないといけない。
むずい。。。

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://aaaxyz.sharepoint.com/sites/test2")
$SecurePassword = "P@ssw0rd!" | ConvertTo-SecureString -AsPlainText -Force
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("kujirai@aaasxyz.onmicrosoft.com", $SecurePassword)

$lists = $ctx.web.Lists
$ctx.Load($lists)
$ctx.ExecuteQuery()

$lists | ?{$_.Hidden -eq $false} | select Title,ItemCount

実行するとこんな感じになる

<スポンサーリンク>

コメントを残す

Allowed tags:  you may use these HTML tags and attributes: <a href="">, <strong>, <em>, <h1>, <h2>, <h3>
Please note:  all comments go through moderation.

*

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)