{"id":2513,"date":"2017-05-15T00:43:42","date_gmt":"2017-05-14T15:43:42","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2513"},"modified":"2020-04-18T20:37:09","modified_gmt":"2020-04-18T11:37:09","slug":"post-2513","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2513","title":{"rendered":"SharePoint \u30ea\u30b9\u30c8\u60c5\u5831\u3092 PowerShell \u3092\u4f7f\u3063\u3066 CSV \u3067\u51fa\u529b\u3059\u308b"},"content":{"rendered":"<p>\u4f53\u8abf\u3082\u60aa\u3044\u306e\u3067\u3001\u30ea\u30b9\u30c8\u60c5\u5831\u3092 CSV \u3067\u51fa\u529b\u3057\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u7acb\u3063\u3066\u30b5\u30af\u30c3\u3068<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\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;your tenant&gt;\/&#039;;\n\n# \u30e6\u30fc\u30b6\u30fc\u540d\n$user = &#039;&lt;your account&gt;&#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\n\n## \u3053\u3053\u304b\u3089\u51e6\u7406\n$ctx.Load($ctx.Web.Lists)\n$ctx.ExecuteQuery();\n\n$data = @()\nfor ($i=0; $i -lt $ctx.Web.lists.Count; $i++) {\n    $t = $ctx.Web.lists[$i]\n    if ($t.Hidden -eq $false -and $t.EntityTypeName.IndexOf(&quot;List&quot;) -ne -1) {\n        $line = @{\n            Title          = $t.Title;\n            Id             = $t.Id;\n            Name           = ($t.EntityTypeName.Substring(0, $t.EntityTypeName.IndexOf(&#039;List&#039;)));\n            Path           = (&quot;{0}\/Lists\/{1}&quot; -f $t.ParentWebUrl.TrimEnd(&#039;\/&#039;), $t.EntityTypeName.Substring(0, $t.EntityTypeName.IndexOf(&#039;List&#039;)));\n            ItemCount      = $t.ItemCount;\n            ItemLastModify = $t.LastItemModifiedDate;\n            ItemLastDelete = $t.LastItemDeletedDate;\n            Created        = $t.Created;\n        }\n        $data += New-Object PSObject -Property $line\n    }\n}\n$data | Export-Csv -LiteralPath &quot;&lt;output path&gt;&quot; -Encoding Default -notype<\/code><\/pre>\n<p>18 \u884c\u76ee\u307e\u3067\u306f\u307b\u307c\u304a\u307e\u3058\u306a\u3044\u3002<\/p>\n<p>27 \u884c\u76ee\u3067\u300cHidden \u3067\u306f\u306a\u304f\u3001\u4e14\u3064\u3001EntityTypeName \u306b List \u3068\u3044\u3046\u6587\u5b57\u304c\u5165\u3063\u3066\u3044\u308b\u3082\u306e\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n32 \u884c\u76ee\u3082\u542b\u3081\u3066\u3067\u3059\u304c\u3001\u3061\u3083\u3093\u3068\u3059\u308b\u306a\u3089\u300cList \u3067\u7d42\u308f\u3063\u3066\u3044\u308b\u300d\u3068\u3084\u3063\u305f\u307b\u3046\u304c\u3088\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>41 \u884c\u76ee\u3067 Export-Csv \u3092\u4f7f\u3063\u3066\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u8003\u5bdf<\/h2>\n<p>32 \u884c\u76ee\u304c\u672c\u5f53\u306b\u3053\u308c\u3067\u3044\u3044\u306e\u304b\u304c\u4e0d\u660e\u3067\u3059\u3002<br \/>\n\u30ea\u30b9\u30c8\u6bce\u306b RootFolder \u3092 Load \u3057\u3066 ServerRelativeUrl \u304b\u3089\u5272\u308a\u51fa\u3059\u306e\u304c\u6b63\u89e3\u306a\u6c17\u304c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30fc\u4e00\u62ec\u5909\u66f4\u306e\u5143\u30c7\u30fc\u30bf\u30fc\u3084\u3001\u4e00\u62ec\u5909\u66f4\u524d\u5f8c\u306e\u78ba\u8a8d\u306a\u3069\u306b\u3053\u3046\u3044\u3046\u306e\u4f7f\u3046\u3060\u308d\u3046\u306a\u30fc<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f53\u8abf\u3082\u60aa\u3044\u306e\u3067\u3001\u30ea\u30b9\u30c8\u60c5\u5831\u3092 CSV \u3067\u51fa\u529b\u3057\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u7acb\u3063\u3066\u30b5\u30af\u30c3\u3068 \u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9 [System.Reflection.Assembly]::LoadWithPartialName(&quot;Microso [&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-2513","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\/2513","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=2513"}],"version-history":[{"count":6,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2513\/revisions"}],"predecessor-version":[{"id":3126,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2513\/revisions\/3126"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}