{"id":2520,"date":"2017-05-28T16:30:28","date_gmt":"2017-05-28T07:30:28","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2520"},"modified":"2020-04-18T20:36:20","modified_gmt":"2020-04-18T11:36:20","slug":"post-2520","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2520","title":{"rendered":"SharePoint Online \u306b\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u624b\u9806(PowerShell)"},"content":{"rendered":"<p>\u3057\u3047\u3042\u307d\u3044\u3093\u3068\u3055\u3093\u3068\u4ef2\u826f\u304f\u306a\u308b\u305f\u3081\u306b\u3001Windows \u3067\u306f\u4e00\u756a\u6163\u308c\u3066\u3044\u308b PowerShell \u3092\u4f7f\u3063\u3066 SharePoint Online \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\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\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\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>SharePoint Online \u3078\u306e\u30ed\u30b0\u30a4\u30f3<\/h2>\n<p>\u30e6\u30fc\u30b6\u30fc\u304c miyamiya@example.com\u3001SharePoint Online \u306e URL \u3092 <code>https:\/\/&lt;tenant&gt;.sharepoint.com\/sites\/example<\/code> \u3068\u4eee\u5b9a\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3002<\/p>\n<pre><code class=\"language-powershell\">[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$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)\n$ctx.Credentials = $credentials<\/code><\/pre>\n<p>\u3053\u3053\u307e\u3067\u306f\u3044\u3064\u3082\u306e\u304a\u307e\u3058\u306a\u3044\u7684\u306a\u30b3\u30fc\u30c9\u3002<br \/>\n\u30ed\u30b0\u30a4\u30f3\u3057\u3066 SharePoint Client Context \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u4f5c\u6210\u3059\u308b\u30ea\u30b9\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6307\u5b9a<\/h2>\n<p>\u3053\u3053\u3067\u306f\u3001\u4f5c\u6210\u6642\u306b\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u3092\u6307\u5b9a\u3057\u3001Web \u30a2\u30c9\u30ec\u30b9\u3092 <code>https:\/\/&lt;tenant&gt;.sharepoint.com\/sites\/example\/Lists\/newList<\/code> \u3068\u3059\u308b\u3053\u3068\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-powershell\">$listInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation\n$listInfo.TemplateType = 100\n$listInfo.Title = &#039;newList&#039;<\/code><\/pre>\n<p>\u6700\u521d\u306b <code>$listInfo<\/code> \u3068\u3057\u3066 ListCreationInformation \u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b <code>TemplateType<\/code> \u306e 100 \u306f\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002  <\/p>\n<ul>\n<li>\u53c2\u8003 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.splisttemplatetype.aspx\">SPListTemplateType enumeration<\/a><\/li>\n<\/ul>\n<p>\u30d6\u30e9\u30a6\u30b6\u3067\u64cd\u4f5c\u3057\u305f\u6642\u3067\u3044\u3046\u3068\u8d64\u67a0\u306e\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p><a href=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2017\/05\/createlist-01.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" src=\"http:\/\/1bed.allright.life\/wp-content\/uploads\/2017\/05\/createlist-01-300x163.png\" alt=\"\" \/><\/a><\/p>\n<p><code>Title<\/code> \u306f\u534a\u89d2\u3067\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u65e5\u672c\u8a9e\u306e\u30bf\u30a4\u30c8\u30eb\u306f\u5225\u3067\u6307\u5b9a\u3057\u307e\u3059\u306e\u3067\u3001\u3053\u3053\u3067\u306f URL \u3068\u3057\u3066\u4f7f\u3044\u305f\u3044\u540d\u524d\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4f5c\u6210\u3055\u308c\u308b <code>Lists<\/code> \u4e0b\u306b\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u305f\u304f\u306a\u3044\u306e\u306a\u3089\u3001 <code>Url<\/code> \u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-powershell\"># Lists \u306e\u4e0b\u306b newList \u3092\u4f5c\u6210\u3059\u308b\u4f8b\n$listInfo.Url = &quot;Lists\/newList&quot;\n\n# example \u76f4\u4e0b\u306b newList \u3092\u4f5c\u6210\u3059\u308b\u4f8b\n$listInfo.Url = &quot;newList&quot;<\/code><\/pre>\n<h2>\u30ea\u30b9\u30c8\u306e\u4f5c\u6210<\/h2>\n<pre><code class=\"language-powershell\">$list = $ctx.Web.Lists.Add($listInfo)\n$list.Title = &quot;\u65b0\u3057\u3044\u30ea\u30b9\u30c8&quot;\n$list.Update()\n$ctx.ExecuteQuery()<\/code><\/pre>\n<p>\u6700\u521d\u306b\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306b ListCreationInformation \u3092\u8ffd\u52a0\u3057\u3066\u3001\u8fd4\u308a\u5024\u306e SPList \u3092 <code>$list<\/code> \u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b <code>Title<\/code> \u3067\u65b0\u3057\u304f\u4f5c\u308b\u30ea\u30b9\u30c8\u306e\u30bf\u30a4\u30c8\u30eb\u3092\u65e5\u672c\u8a9e\u3067\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b SPList \u3092 <code>Update<\/code> \u3057\u3066\u3001\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3092 <code>ExecuteQuery<\/code> \u3067\u53cd\u6620\u3055\u305b\u307e\u3059\u3002<\/p>\n<h2>\u8003\u5bdf<\/h2>\n<p>\u3053\u308c\u3067\u65e5\u672c\u8a9e\u30bf\u30a4\u30c8\u30eb\u3092\u4f7f\u3046\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u306e\u4f5c\u6210\u3067\u3001\u4e00\u756a\u5358\u7d14\u306a\u4f5c\u6210\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<p>SourceID \u3092\u6307\u5b9a\u3057\u306a\u3044\u3068 OpenXML SDK \u3092\u4f7f\u3063\u3066\u306a\u3093\u3084\u304b\u3093\u3084\u3059\u308b\u6642\u306b\u554f\u984c\u304c\u8d77\u304d\u308b\u3088\uff01\u3068\u3044\u3046\u8a71\u3082\u898b\u307e\u3057\u305f\u304c\u3001\u3061\u3087\u3063\u3068\u72b6\u6cc1\u304c\u60f3\u50cf\u3067\u304d\u306a\u304b\u3063\u305f\u306e\u3067\u982d\u306e\u7247\u9685\u306b\u7f6e\u3044\u3066\u304a\u304f\u3053\u3068\u306b\u3057\u307e\u3059&#8230;<\/p>\n<p>\u6b21\u306e\u8a18\u4e8b\u3067\u306f\u3001\u305d\u306e\u4ed6\u306e\u8a2d\u5b9a\u3092 PowerShell \u304b\u3089\u3084\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>\u53c2\u8003<\/h2>\n<ul>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.client.listcreationinformation_members.aspx\">MSDN: ListCreationInformation members<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/microsoft.sharepoint.splisttemplatetype.aspx\">MSDN: SPListTemplateType enumeration<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/EN-US\/library\/microsoft.sharepoint.splist_properties.aspx\">MSDN: SPList properties<\/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\u3001Windows \u3067\u306f\u4e00\u756a\u6163\u308c\u3066\u3044\u308b PowerShell \u3092\u4f7f\u3063\u3066 SharePoint Online \u3078\u30a2\u30af\u30bb\u30b9\u3057\u3066\u30ab\u30b9\u30bf\u30e0\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u30e1\u30e2\u3002 CSOM (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5074\u30aa [&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-2520","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\/2520","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=2520"}],"version-history":[{"count":6,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2520\/revisions"}],"predecessor-version":[{"id":3125,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2520\/revisions\/3125"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}