【问题标题】:Easy way to generate a contents list and/or site map for a SharePoint Online site?为 SharePoint Online 网站生成内容列表和/或网站地图的简单方法?
【发布时间】:2021-12-13 22:31:56
【问题描述】:

我和我的同事继承了一个笨重的 SharePoint (SharePoint Online) 网站,我的任务是实施更好的组织。第一步是弄清楚站点中的所有内容 - 理想情况下,我想创建一个站点地图,但即使是文档列表也会有所帮助。我在这里询问是否有人有他们过去用于此目的的快捷方式和/或一些代码。我们已经尝试过 sharepoint 拥有的文件报告工具,但它失败了。我们还尝试了我在此处找到的脚本 [如何使用 Powershell 列出 SharePoint 站点中的所有文档][1],但它也未能给出完整的列表。

感谢您的帮助。

尝试了 Emily Du 于 10/29 提出的建议,但出现错误 -

[错误截图][2]

#Connect to Site collection

Connect-PnPOnline -Url $SiteURL -UseWebLogin Connect-PnPOnline :术语“Connect-PnPOnline”未被识别为 cmdlet、函数、脚本文件或 可运行的程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确并尝试 再次。 在 line:1 char:1

  • Connect-PnPOnline -Url $SiteURL -UseWebLogin
  •   + CategoryInfo          : ObjectNotFound: (Connect-PnPOnline:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    

#调用 Web 和所有子网的函数 获取 PnPWeb |获取文档库存 Get-PnPWeb:术语“Get-PnPWeb”未被识别为 cmdlet、函数、脚本文件或可操作的名称 程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试。 在 line:1 char:1

  • 获取 PnPWeb |获取文档清单
  •   + CategoryInfo          : ObjectNotFound: (Get-PnPWeb:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

PGet-PnPSubWebs -Recurse| ForEach-Object { Get-DocumentInventory $_ } Get-PnPSubWebs :术语“Get-PnPSubWebs”未被识别为 cmdlet、函数、脚本文件或 可运行的程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确并尝试 再次。 在 line:1 char:1

  • 获取-PnPSubWebs -递归| ForEach-Object { Get-DocumentInventory $_ }
  •   + CategoryInfo          : ObjectNotFound: (Get-PnPSubWebs:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

断开连接-PnPOnline Disconnect-PnPOnline :“Disconnect-PnPOnline”一词未被识别为 cmdlet、函数、脚本的名称 文件或可运行的程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确 然后再试一次。 在 line:1 char:1

  • 断开连接-PnPOnline
  •   + CategoryInfo          : ObjectNotFound: (Disconnect-PnPOnline:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    
    [1]: https://collab365.com/list-all-documents/
    [2]: https://i.stack.imgur.com/YWsOL.jpg
    

【问题讨论】:

    标签: sharepoint


    【解决方案1】:

    您可以使用以下 PnP PowerShell 将所有文件从给定网站集的所有文档库中获取到 CSV 文件。

    #Parameters
    $SiteURL = "https://tenant.SharePoint.com/sites/test"
    $CSVPath = "C:\Temp\DocumentInventory.csv"
    $global:DocumentInventory = @()
    $Pagesize = 2000
     
    #Function to scan and collect Document Inventory
    Function Get-DocumentInventory
    {
         [cmdletbinding()]
        param([parameter(Mandatory = $true, ValueFromPipeline = $true)] $Web)
       
        Write-host "Getting Documents Inventory from Site '$($Web.URL)'" -f Yellow
        #Calculate the URL of the tenant
        If($Web.ServerRelativeUrl -eq "/")
        {
            $TenantURL = $Web.Url
        }
        Else
        {
            $TenantURL = $Web.Url.Replace($Web.ServerRelativeUrl,'')
        }
     
        #Exclude certain libraries
        $ExcludedLists = @("Form Templates", "Preservation Hold Library","Site Assets", "Pages", "Site Pages", "Images",
                                "Site Collection Documents", "Site Collection Images","Style Library")
                                   
        #Get All Document Libraries from the Web
        Get-PnPList -Web $Web -PipelineVariable List | Where-Object {$_.BaseType -eq "DocumentLibrary" -and $_.Hidden -eq $false -and $_.Title -notin $ExcludedLists -and $_.ItemCount -gt 0} | ForEach-Object {
            #Get Items from List  
            $global:counter = 0;
            $ListItems = Get-PnPListItem -List $_ -Web $web -PageSize $Pagesize -Fields Author, Created, File_x0020_Type -ScriptBlock `
                     { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ($global:Counter / ($_.ItemCount) * 100) -Activity "Getting Documents from '$($_.Title)'" -Status "Processing Items $global:Counter to $($_.ItemCount)";} | Where {$_.FileSystemObjectType -eq "File"}
            Write-Progress -Activity "Completed Retrieving Documents from Library $($List.Title)" -Completed
         
                #Get Root folder of the List
                $Folder = Get-PnPProperty -ClientObject $_ -Property RootFolder
     
                #Iterate through each document and collect data          
                ForEach($ListItem in $ListItems)
                { 
                    #Collect document data
                    $global:DocumentInventory += New-Object PSObject -Property ([ordered]@{
                        SiteName  = $Web.Title
                        SiteURL  = $Web.URL
                        LibraryName = $List.Title
                        ParentFolder = $Folder.ServerRelativeURL
                        FileName = $ListItem.FieldValues.FileLeafRef
                        FileType = $ListItem.FieldValues.File_x0020_Type
                        AbsoluteURL = "$TenantURL$($ListItem.FieldValues.FileRef)"
                        CreatedBy = $ListItem.FieldValues.Author.Email
                        CreatedAt = $ListItem.FieldValues.Created
                        ModifiedBy = $ListItem.FieldValues.Editor.Email
                        ModifiedAt = $ListItem.FieldValues.Modified
                    })
                }
            }
    }
      
    #Connect to Site collection
    Connect-PnPOnline -Url $SiteURL -UseWebLogin
        
    #Call the Function for Web & all Subwebs
    Get-PnPWeb | Get-DocumentInventory
    Get-PnPSubWebs -Recurse| ForEach-Object { Get-DocumentInventory $_ }
    Disconnect-PnPOnline
       
    #Export Documents Inventory to CSV
    $Global:DocumentInventory | Export-Csv $CSVPath -NoTypeInformation
    Write-host "Documents Inventory Report has been Exported to '$CSVPath'"  -f Green 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-30
      • 2012-02-26
      • 2011-03-29
      • 2018-10-16
      • 1970-01-01
      相关资源
      最近更新 更多