当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 查找 SharePoint Online 中的所有 InfoPath 表单库

作者:精品下载站 日期:2024-12-14 21:26:34 浏览:13 分类:玩电脑

使用 PowerShell 查找 SharePoint Online 中的所有 InfoPath 表单库


要求:在 SharePoint Online 中查找所有 InfoPath 表单库。

如何查找 SharePoint Online 网站中的所有 InfoPath 表单库?

在 SharePoint Online 中,InfoPath 表单可以存储在表单库中,表单库是一种特殊类型的文档库,旨在存储和管理 InfoPath 表单。如果需要查找 SharePoint Online 环境中的所有 InfoPath 表单库,可以使用 PowerShell。在本教程中,我们将讨论如何使用 PowerShell 查找 SharePoint Online 中的所有 InfoPath 表单库。

若要获取 SharePoint Online 网站集中的所有表单库,请使用以下 PowerShell 脚本。此脚本检查任何列表的模板 ID 是否为 115,以确定它是否是 XML 表单库(SharePoint Online 列表模板 ID 参考)。


#Function to Get Form Libraries
Function Get-PnPFormLibraries
{
[cmdletbinding()]
 
    param(
    [parameter(Mandatory = $true, ValueFromPipeline = $True)]$Web,
    [parameter(Mandatory = $true, ValueFromPipeline = $False)][String] $CSVPath
    )
   
    Try {
        Write-host "Searching Web '$($Web.URL)'" -f Yellow
         
        #Get All Form libraries
        $Lists= Get-PnPProperty -ClientObject $Web -Property Lists 
        $FormLibraries = $Lists | Where-Object {$_.BaseTemplate -eq 115 -and $_.Hidden -eq $false}
 
        #Export Form Libraries Inventory to CSV
        If($FormLibraries.count -gt 0)
        {
            Write-host "`tFound '$($FormLibraries.count)' Form Librarie(s)!" -f Green
            $FormLibraries | Select Title, DefaultViewUrl, Created | Export-Csv -Path $CSVPath -NoTypeInformation -Append
        }
    }
    catch {
        write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
    }
}
 
#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$CSVPath = "C:\Temp\FormLibs.csv"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get All Webs in the site collection and Iterate through
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb
 
#Delete the Output Report if exists
If (Test-Path $CSVPath) { Remove-Item $CSVPath }

ForEach($Web in $Webs)
{ 
    #Call the function
    Get-PnPFormLibraries -Web $Web -CSVPath $CSVPath
}

此 PowerShell 脚本扫描并提取给定网站集及其所有子网站中存在的 InfoPath 表单库。要扫描租户所有站点中的 Infopath 库,请使用以下命令:


#Parameters
$Domain =  "CrescentIntranet" #Your Domain Name in SharePoint Online. E.g. https://Crescent.sharepoint.com
$CSVPath = "C:\Temp\InfoPathRpt.csv"
$Cred = Get-Credential

#Frame Tenant URL and Tenant Admin URL
$TenantURL = "https://$Domain.SharePoint.com"
$TenantAdminURL = "https://$Domain-Admin.SharePoint.com"

#Function to Get Form Libraries
Function Get-PnPFormLibraries
{
[cmdletbinding()]

    param(
    [parameter(Mandatory = $true, ValueFromPipeline = $False)]$Web,
    [parameter(Mandatory = $False, ValueFromPipeline = $False)][String] $CSVPath
    )
  
    Try {
        Write-host "`tSearching Web '$($Web.URL)'" -f Yellow
        
        #Get All Form libraries
        $Lists= Get-PnPProperty -ClientObject $Web -Property Lists 
        $FormLibraries = $Lists | Where-Object {$_.BaseTemplate -eq 115 -and $_.Hidden -eq $false}

        #Export Form Libraries Inventory to CSV
        If($FormLibraries.count -gt 0)
        {
            Write-host "`tFound '$($FormLibraries.count)' Form Librarie(s)!" -f Green
            $FormLibraries | Select Title, DefaultViewUrl, Created | Export-Csv -Path $CSVPath -NoTypeInformation -Append
        }
    }
    catch {
        write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
    }
}

#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
    
#Get All Site collections - Exclude BOT, Video Portals and MySites
$Sites = Get-PnPTenantSite -Filter "Url -like $TenantURL -and Url -notlike '-my.sharepoint.com/' -and Url -notlike '/portals/'"
   
#Iterate through all site collections
$Sites | ForEach-Object {
    #Connect to each site collection
    Connect-PnPOnline -Url $_.URL -Credentials $Cred
    
    Write-host "`nProcessing Site Collection:"$_.URL -ForegroundColor Magenta
    #Get All Webs in the site collection and Iterate through
    Get-PnPSubWeb -Recurse -IncludeRootWeb | ForEach-Object {Get-PnPFormLibraries -Web $_ -CSVPath $CSVPath}
}

这是另一篇文章,用于获取本地 SharePoint 中的所有信息路径表单:PowerShell to Find All InfoPath Form Libraries in SharePoint

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯