{"id":2592,"date":"2017-11-01T02:24:54","date_gmt":"2017-10-31T17:24:54","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2592"},"modified":"2020-04-18T20:22:55","modified_gmt":"2020-04-18T11:22:55","slug":"post-2592","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2592","title":{"rendered":"SharePoint Online \u3067\u9078\u629e\u80a2\u5217\u3068\u53c2\u7167\u5217\u3092 PowerShell \u3067\u4ed8\u3051\u66ff\u3048\u308b(1\/3)"},"content":{"rendered":"<p>\u9078\u629e\u80a2\u5217\u3092\u53c2\u7167\u5217\u306b\u5165\u308c\u66ff\u3048\u308b\u6642\u306b\u306f\u3069\u3046\u3059\u308b\u306e\u304b\uff1f<br \/>\n\u305d\u308c\u306f\u6211\u3005\u306b\u6c38\u9060\u306e\u8ab2\u984c\u3067\u3042\u308b\uff08\u5618<\/p>\n<p>\u5f53\u521d\u306f\u9078\u629e\u80a2\u5217\u3067\u4f5c\u3063\u3066\u3044\u305f\u304c\u3001\u904b\u7528\u3057\u3066\u3044\u304f\u3068\u30de\u30b9\u30bf\u5316\u3057\u305f\u304f\u306a\u308a\u3001\u53c2\u7167\u5217\u306b\u5909\u66f4\u3057\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u4f46\u3057\u3001\u53c2\u7167\u5217\u306b\u3059\u308b\u3068\u30a2\u30a4\u30c6\u30e0\u3092\u6b8b\u3057\u7d9a\u3051\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u30ab\u30eb\u30de\u3092\u80cc\u8ca0\u3046\u305f\u3081\u3001\u4e0a\u624b\u304f\u5148\u3092\u898b\u8d8a\u3055\u306a\u3044\u3068\u300cxxxxx (\u4f7f\u7528\u7981\u6b62)\u300d\u3068\u304b\u300cxxxx (yyyy.mm.dd \u307e\u3067\u4f7f\u7528)\u300d\u3068\u304b\u3044\u3046\u8d85\u7d76\u30c0\u30b5\u3044\u30de\u30b9\u30bf\u306b\u306a\u3063\u3066\u3044\u304d\u3001\u672a\u6765\u6c38\u52ab\u3001\u88cf\u3067\u30b3\u30bd\u30b3\u30bd\u8a00\u308f\u308c\u308b\u306e\u3067\u6c17\u3092\u3064\u3051\u307e\u3057\u3087\u3046\uff08\u8a00\u3044\u904e\u304e<br \/>\n\u3000\uff03\u53c2\u7167\u5217\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308c\u3070\u6559\u3048\u3066\u304f\u3060\u3055\u3044&#8230; orz<\/p>\n<p>\u3055\u3066\u3001\u9078\u629e\u80a2\u5217\u3092\u53c2\u7167\u5217\u306b\u7f6e\u304d\u63db\u3048\u308b\u6642\u306f\u3001\u6050\u3089\u304f\u6b21\u306e\u624b\u9806\u306a\u611f\u3058\u306b\u306a\u308b\u3068\u601d\u3046<\/p>\n<ol>\n<li>\u9078\u629e\u80a2\u5217\u306e\u5024\u3092\u4f7f\u3044\u3001\u53c2\u7167\u5217\u5143\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/li>\n<li>\u624b\u9806 1 \u3067\u4f5c\u6210\u3057\u305f\u30ea\u30b9\u30c8\u3092\u4f7f\u3044\u3001\u53c2\u7167\u5217\u3092\u4f5c\u6210\u3059\u308b<\/li>\n<li>\u9078\u629e\u80a2\u5217\u306e\u5024\u3092\u53c2\u7167\u5217\u306b\u79fb\u884c<\/li>\n<li>\u9078\u629e\u80a2\u5217\u306e\u524a\u9664<br \/>\n\uff03\u5b9f\u969b\u306f\u975e\u8868\u793a\u5217\u306b\u3057\u3066\u3001\u52d5\u4f5c\u78ba\u8a8d\u5f8c\u306b\u524a\u9664\u3059\u308b\u3068\u3044\u3046\u306e\u304c\u826f\u3044\u304b\u3068\u601d\u3046<\/li>\n<\/ol>\n<p>\u4e0a\u8a18\u624b\u9806\u306e 1 \uff5e 3 \u3092 PowerShell \u3067\u3084\u3063\u3066\u307f\u3088\u3046\u3068\u601d\u3046<\/p>\n<p>\u4eca\u56de\u306f\u300c1. \u9078\u629e\u80a2\u5217\u306e\u5024\u3092\u4f7f\u3044\u3001\u53c2\u7167\u5217\u5143\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u300d\u3092\u884c\u3046<\/p>\n<h2>\u74b0\u5883<\/h2>\n<p>SharePoint Online \u306b\u6b21\u306e\u30ea\u30b9\u30c8\u6e96\u5099<\/p>\n<ul>\n<li>\n<table>\n<thead>\n<tr>\n<th>\u30ea\u30b9\u30c8\u540d: \u9078\u629e\u80a2\u5217\u3068\u53c2\u7167\u5217\u3092\u4ed8\u3051\u66ff\u3048\u308b<\/th>\n<th>\u5217\u540d<\/th>\n<th>\u5185\u90e8\u5217\u540d<\/th>\n<th>\u7a2e\u985e<\/th>\n<th>\u5024<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u76ee\u7684\u5730<\/td>\n<td>Title<\/td>\n<td>1 \u884c\u30c6\u30ad\u30b9\u30c8<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u4e57\u308a\u7269<\/td>\n<td>vehicle<\/td>\n<td>\u9078\u629e\u80a2<\/td>\n<td>\u8eca , \u30d0\u30a4\u30af , \u81ea\u8ee2\u8eca , \u8239 , \u98db\u884c\u6a5f<\/td>\n<\/tr>\n<tr>\n<td>\u304a\u3084\u3064<\/td>\n<td>snack<\/td>\n<td>\u9078\u629e\u80a2(\u8907\u6570\u9078\u629e\u53ef\u80fd)<\/td>\n<td>\u30dd\u30c6\u30c8\u30c1\u30c3\u30d7\u30b9 , \u30a2\u30dd\u30ed , \u3058\u3083\u304c\u308a\u3053 , \u30c1\u30c3\u30d7\u30b9\u30bf\u30fc , \u30cf\u30a4\u30ec\u30e2\u30f3 , \u304b\u3063\u3071\u3048\u3073\u305b\u3093<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<table>\n<thead>\n<tr>\n<th>\u9078\u629e\u80a2\u5217\u304b\u3089\u4f5c\u6210\u3055\u308c\u308b\u53c2\u7167\u5143\u30ea\u30b9\u30c8(\u30de\u30b9\u30bf\u30ea\u30b9\u30c8)<\/th>\n<th>\u5217\u540d<\/th>\n<th>\u751f\u6210\u3055\u308c\u308b\u30ea\u30b9\u30c8\u540d<\/th>\n<th>\u30ea\u30b9\u30c8\u306e\u30bf\u30a4\u30c8\u30eb<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u4e57\u308a\u7269<\/td>\n<td>\u4e57\u308a\u7269\u30de\u30b9\u30bf<\/td>\n<td>vehicleMst<\/td>\n<\/tr>\n<tr>\n<td>\u304a\u3084\u3064<\/td>\n<td>\u304a\u3084\u3064\u30de\u30b9\u30bf<\/td>\n<td>snackMst<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<h2>1. \u9078\u629e\u80a2\u5217\u306e\u5024\u3092\u4f7f\u3044\u3001\u53c2\u7167\u5217\u5143\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<pre><code class=\"language-powershell\">[void][System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SharePoint.Client&quot;)\n[void][System.Reflection.Assembly]::LoadWithPartialName(&quot;Microsoft.SharePoint.Client.Runtime&quot;)\n\n# SharePoint Online \u306e URL\n$url = &#039;https:\/\/&lt;tenant&gt;.sharepoint.com\/sites\/example&#039;\n# \u30e6\u30fc\u30b6\u30fc\u540d\n$user = &#039;miyamiya@example.com&#039;;\n# \u30d1\u30b9\u30ef\u30fc\u30c9\n$secure = Read-Host -Prompt &quot;Enter the password for ${user}(Office365)&quot; -AsSecureString;\n# SharePoint Online \u8a8d\u8a3c\u60c5\u5831\n$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($user, $secure);\n# SharePoint Client Context \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u751f\u6210\n$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)\n$ctx.Credentials = $credentials\n\n## \u3053\u3053\u307e\u3067\u306f\u3044\u3064\u3082\u306e\u304a\u307e\u3058\u306a\u3044\u7684\u306a\u30b3\u30fc\u30c9\u3002\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\n\n# \u9078\u629e\u80a2\u5217\u3092\u53c2\u7167\u5217\u306b\u7f6e\u304d\u63db\u3048\u308b\u30ea\u30b9\u30c8\u306e\u30ea\u30b9\u30c8\u540d\n$ListName         = &quot;\u9078\u629e\u80a2\u5217\u3068\u53c2\u7167\u5217\u3092\u4ed8\u3051\u66ff\u3048\u308b&quot;\n# \u53c2\u7167\u5217\u5316\u3059\u308b\u5217\u540d\n$fieldName        = &quot;\u4e57\u308a\u7269&quot;\n# \u30de\u30b9\u30bf\u30ea\u30b9\u30c8\u306e\u30bf\u30a4\u30c8\u30eb\n$convertListTitle = &quot;vehicleMst&quot;\n# \u30de\u30b9\u30bf\u30ea\u30b9\u30c8\u306e\u540d\u524d\n$convertListName  = &quot;\u4e57\u308a\u7269\u30de\u30b9\u30bf&quot;\n\n# \u30ea\u30b9\u30c8\u306e\u53d6\u5f97\n$list = $ctx.Web.Lists.GetByTitle($ListName)\n# \u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u53d6\u5f97\n$field = $list.Fields.GetByInternalNameOrTitle($fieldName)\n# \u5024\u306e\u30ed\u30fc\u30c9\n$ctx.Load($field)\n$ctx.ExecuteQuery()\n\n# \u9078\u629e\u80a2\u5217\u3067\u306a\u3044\u6642\u306f\u51e6\u7406\u3092\u7d42\u4e86\u3059\u308b\nif ($field.TypeAsString.ToUpper() -ne &#039;CHOICE&#039; -and $field.TypeAsString.ToUpper() -ne &#039;MULTICHOICE&#039;) {\n    exit\n}\n\n# \u30de\u30b9\u30bf\u30ea\u30b9\u30c8\u306e\u4f5c\u6210\n$listInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation\n$listInfo.TemplateType = 100\n$listInfo.Title = $convertListTitle\n$listInfo.Url = &quot;Lists\/$convertListTitle&quot;\n\n$mstlist = $ctx.Web.Lists.Add($listInfo)\n$mstlist.Title = $convertListName\n$mstlist.Update()\n$ctx.ExecuteQuery()\n\n# \u30de\u30b9\u30bf\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\nforeach($value in $field.TypedObject.Choices) {\n    $itemCreateInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation\n    $item = $mstlist.AddItem($itemCreateInfo)\n    $item[&#039;Title&#039;] = $value\n    $item.Update()\n}\n$ctx.ExecuteQuery()\n\n# \u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u7834\u68c4\n$ctx.Dispose()<\/code><\/pre>\n<p>\u30de\u30b9\u30bf\u30ea\u30b9\u30c8\u306e\u4f5c\u6210\u306f\u4ee5\u524d\u306b\u8a73\u3057\u304f\u7d39\u4ecb\u3057\u3066\u3044\u308b\u306e\u3067\u305d\u3061\u3089\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li><a href=\"http:\/\/1bed.allright.life\/?p=2520\">Blog : SharePoint Online \u306b\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u624b\u9806(PowerShell)<\/a> <\/li>\n<\/ul>\n<p>\u30de\u30b9\u30bf\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\u3067\u306f\u3001\u30ea\u30b9\u30c8\u306e\u5217\u60c5\u5831\u306b\u3042\u308b\u9078\u629e\u80a2\u5217\u306e\u5024\u306e\u5206\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3001\u66f4\u65b0\u4e88\u7d04\u3092\u884c\u3044\u3001\u6700\u5f8c\u306b\u4e00\u6c17\u306b ExecuteQuery \u3067\u66f4\u65b0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3042\u3068\u306f\u3001\u3082\u3046\u4e00\u3064\u306e\u9078\u629e\u80a2\u5217\u300c\u304a\u3084\u3064\u300d\u3092\u4f7f\u3063\u3066\u300c\u304a\u3084\u3064\u30de\u30b9\u30bf\u300d\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306e 21 \uff5e 26 \u884c\u76ee\u3092\u5909\u66f4\u3057\u3066\u3082\u3046\u4e00\u5ea6\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u4f7f\u3046\u30b3\u30fc\u30c9\u306e\u6642\u306f\u3001\u5916\u90e8\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u6b21\u306e\u3088\u3046\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3001\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u52a0\u3048\u3066\u3082\u826f\u3044\u3068\u306f\u601d\u3046\u3002<\/p>\n<pre><code class=\"language-powershell\">$target = @()\n$target += @{\n    fieldName        = &quot;\u4e57\u308a\u7269&quot;;\n    convertListTitle = &quot;vehicleMst&quot;;\n    convertListName  = &quot;\u4e57\u308a\u7269\u30de\u30b9\u30bf&quot;;\n}\n$target += @{\n    fieldName        = &quot;\u304a\u3084\u3064&quot;;\n    convertListTitle = &quot;snackMst&quot;;\n    convertListName  = &quot;\u304a\u3084\u3064\u30de\u30b9\u30bf&quot;;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9078\u629e\u80a2\u5217\u3092\u53c2\u7167\u5217\u306b\u5165\u308c\u66ff\u3048\u308b\u6642\u306b\u306f\u3069\u3046\u3059\u308b\u306e\u304b\uff1f \u305d\u308c\u306f\u6211\u3005\u306b\u6c38\u9060\u306e\u8ab2\u984c\u3067\u3042\u308b\uff08\u5618 \u5f53\u521d\u306f\u9078\u629e\u80a2\u5217\u3067\u4f5c\u3063\u3066\u3044\u305f\u304c\u3001\u904b\u7528\u3057\u3066\u3044\u304f\u3068\u30de\u30b9\u30bf\u5316\u3057\u305f\u304f\u306a\u308a\u3001\u53c2\u7167\u5217\u306b\u5909\u66f4\u3057\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002 \u4f46\u3057\u3001\u53c2\u7167\u5217\u306b [&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-2592","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\/2592","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=2592"}],"version-history":[{"count":14,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2592\/revisions"}],"predecessor-version":[{"id":3119,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2592\/revisions\/3119"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}