{"id":2457,"date":"2017-04-16T21:06:47","date_gmt":"2017-04-16T12:06:47","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2457"},"modified":"2020-04-18T20:43:22","modified_gmt":"2020-04-18T11:43:22","slug":"post-2457","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2457","title":{"rendered":"PowerShell \u3067 SharePoint Online \u306b CSOM \u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p>\u3057\u3047\u3042\u307d\u3044\u3093\u3068\u3055\u3093\u3068\u4ef2\u826f\u304f\u306a\u308b\u305f\u3081\u306b\u3001\u307e\u305a\u306f Windows \u3067\u306f\u4e00\u756a\u6163\u308c\u3066\u3044\u308b PowerShell \u3092\u4f7f\u3063\u3066 SharePoint Online \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u305f\u30e1\u30e2\u3002<\/p>\n<p>CSOM (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 \u30e2\u30c7\u30eb) \u3092\u4f7f\u3063\u3066\u3001\u30ea\u30b9\u30c8\u4e00\u89a7\u3092\u53d6\u5f97\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>\u74b0\u5883<\/h2>\n<ul>\n<li>Windows 10 Pro<\/li>\n<li>PowerShell 5.1<\/li>\n<\/ul>\n<h2>\u4e8b\u524d\u6e96\u5099<\/h2>\n<p>SharePoint Online \u7528\u306e SDK \u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u6642\u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>SharePoint Online Client Components SDK \u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n<a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42038\">https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=42038)<\/a><br \/>\n\u203b64 bit \u3068 32 bit \u3092\u9593\u9055\u308f\u306a\u3044\u3088\u3046\u306b<\/li>\n<\/ul>\n<h2>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c miyamiya@example.com\u3001SharePoint Online \u306e URL \u304c <a href=\"https:\/\/&amp;lt;tenant&gt;.sharepoint.com\/sites\/example\">https:\/\/&lt;tenant>.sharepoint.com\/sites\/example<\/a> \u3068\u4eee\u5b9a\u3057\u3066\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u66f8\u304f\u3002<\/p>\n<pre><code class=\"language-powershell\"># SDK \u306e\u8aad\u307f\u8fbc\u307f\n[System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SharePoint.Client&quot;) | Out-Null\n[System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SharePoint.Client.Runtime&quot;) | Out-Null\n\n# \u53d6\u5f97\u3059\u308b SharePoint Online \u306e URL\n$url    = &#039;https:\/\/&lt;tenant&gt;.sharepoint.com\/sites\/example&#039;;\n\n# \u30e6\u30fc\u30b6\u30fc\u540d\n$user   = &#039;miyamiya@example.com&#039;;\n\n# \u30d1\u30b9\u30ef\u30fc\u30c9\n$secure = Read-Host -Prompt &quot;Enter the password for ${user}(Office365)&quot; -AsSecureString;\n\n# SharePoint Online \u8a8d\u8a3c\u60c5\u5831\n$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($user, $secure);\n\n# SharePoint Client Context \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\n$context = New-Object Microsoft.SharePoint.Client.ClientContext($url)\n$context.Credentials = $credentials\n\n# \u30b5\u30a4\u30c8\u306b\u3042\u308b\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\n$lists = $context.Web.Lists\n\n# \u53d6\u5f97\u4e88\u7d04\n$context.Load($lists)\n\n# \u30ea\u30b9\u30c8\u53d6\u5f97\u5b9f\u884c\n$context.ExecuteQuery()\n\n# \u30ea\u30b9\u30c8\u306e\u4f5c\u6210\u65e5\u6642\u3068\u30bf\u30a4\u30c8\u30eb\u3092\u8868\u793a\n$lists | %{ &quot;Created: {0}, Title: {1}&quot; -f $_.Created, $_.Title }<\/code><\/pre>\n<h2>\u8003\u5bdf<\/h2>\n<p>\u4e00\u65e6 Load \u3067\u4e88\u7d04\u3057\u3066\u3001ExecuteQuery \u3067\u5b9f\u969b\u306b\u53d6\u5f97\u3059\u308b\u306e\u304c\u6163\u308c\u308b\u306e\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u305d\u3046\u3002<\/p>\n<h2>\u53c2\u8003<\/h2>\n<ul>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/sharepoint_support\/2014\/10\/19\/sharepoint-online-powershell\/\">SharePoint Online \u306b\u5bfe\u3057\u3066 PowerShell \u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3057\u3047\u3042\u307d\u3044\u3093\u3068\u3055\u3093\u3068\u4ef2\u826f\u304f\u306a\u308b\u305f\u3081\u306b\u3001\u307e\u305a\u306f Windows \u3067\u306f\u4e00\u756a\u6163\u308c\u3066\u3044\u308b PowerShell \u3092\u4f7f\u3063\u3066 SharePoint Online \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u305f\u30e1\u30e2\u3002 CSOM (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 \u30e2\u30c7 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,111],"tags":[62],"class_list":["post-2457","post","type-post","status-publish","format-standard","hentry","category-program","category-sharepoint","tag-powershell"],"_links":{"self":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2457"}],"version-history":[{"count":2,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2457\/revisions"}],"predecessor-version":[{"id":3129,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2457\/revisions\/3129"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}