Is there a way to get the list of InfoPath forms hosted in form libraries, list inside an entire site collection in SharePoint Online
The output should give,
Site Name:
Site URL:
SharePoint List/Library Name:
Thanks!
Is there a way to get the list of InfoPath forms hosted in form libraries, list inside an entire site collection in SharePoint Online
The output should give,
Site Name:
Site URL:
SharePoint List/Library Name:
Thanks!
You can do this with the PNP cmdlets. (https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps)
Install-Module SharePointPnPPowerShellOnline
The following works, but I don't think it is ideal (reconnects for each web). Delete the Write-Host line to remove the "checking" messages.
$rootUrl = "https://yourDomain.sharepoint.com" # enter your URL
$cred = Get-Credential # enter credential with needed permissions
Connect-PnPonline $rootUrl -credential $cred;
Get-PnPTenantSite |
foreach {
Connect-PnPonline $_.url -credential $cred;
#####Get-PnPWeb -Includes webs |
##### select -ExpandProperty webs |
Get-PnPSubWebs -Recurse |
where { $_.url -like $rootUrl+"*" } | # skip app sites and OneDrives
foreach {
Write-Host "Checking " $_.Url; # status message, delete if not needed.
$parentTitle = $_.Title;
$parentUrl = $_.Url;
Get-PnPList -Web $_ -Includes Forms |
foreach { $listTitle = $_.Title; $_ } |
select -ExpandProperty Forms |
where { $_.ServerRelativeUrl -like '*displayifs.aspx' } |
select @{l="Web Title";e={$parentTitle}},
@{l="Web URL";e={$parentUrl}},
@{l="List Title";e={$listTitle}}
}
}
Borrowed some of the Script from Mike but I changed it to look at Doc Libraries as well as lists. This script connects to each parent and child / site collection and checks for lists and libraries and excludes system lists. For Lists it checks the form URL and for Doc Libraries it checks if the Form Content Type is in use (which is usually the case if an InfoPath library is) on that site. I'm sure there are other ways but I thought I'd share how I was able to get a script to generate all sites using InfoPath forms.
$rootUrl = "https://yourDomain.sharepoint.com" # enter your URL
Connect-PnPonline $rootUrl
Get-PnPTenantSite |
foreach {
Write-Host "Checking " $_.Url; # status message, delete if not needed.
Connect-PnPonline $_.url
$web = Get-PnPWeb
$parentTitle = $web.Title
$parentUrl = $web.Url
$listsIncForm = Get-PnPList
forEach ( $list in $listsIncForm) {
$listTitle = $list.Title
$listType = $list.BaseTemplate
$listUrl = $list.DefaultViewUrl
if ( $listType -eq 100 -or $listType -eq 101 ) {
$currList = Get-PnPList $listTitle -Includes ContentTypes, Forms, IsSystemList
$listForms = $currList.Forms
$isSysList = $currList.IsSystemList
if ( $isSysList ) {
#Write-Host 'Sys List Ignore'
} else {
if ( $listType -eq 101 ) {
$contentTAllow = $currList.AllowContentTypes
if ( $contentTAllow ) {
$contentTyps = $currList.ContentTypes
forEach ($contType in $contentTyps) {
if ( $contType.Name -eq 'Form' ) {
Write-Host "InfoPath Found in Library" $listTitle " at URL " $listUrl -ForegroundColor Green
}
}
}
}
else {
forEach ( $listFm in $listForms ) {
$listPath = $listFm.ServerRelativeUrl
if ( $listPath -like '*displayifs.aspx' ) {
Write-Host 'InfoPath Found in List ' $listTitle " at URL " $listUrl -ForegroundColor Green
}
}
}
}
}
}
Get-PnPSubWebs -Recurse |
where { $_.url -like $rootUrl+"*" } | # skip app sites and OneDrives
foreach {
Write-Host "Checking " $_.Url; # status message, delete if not needed.
Connect-PnPOnline -Url $_.Url
$web = Get-PnPWeb
$parentTitle = $web.Title
$parentUrl = $web.Url
$listsIncForm = Get-PnPList
forEach ( $list in $listsIncForm) {
$listTitle = $list.Title
$listType = $list.BaseTemplate
$listUrl = $list.DefaultViewUrl
if ( $listType -eq 100 -or $listType -eq 101 ) {
$currList = Get-PnPList $listTitle -Includes ContentTypes, Forms, IsSystemList
$listForms = $currList.Forms
$isSysList = $currList.IsSystemList
if ( $isSysList ) {
#Write-Host 'Sys List Ignore'
} else {
if ( $listType -eq 101 ) {
$contentTAllow = $currList.AllowContentTypes
if ( $contentTAllow ) {
$contentTyps = $currList.ContentTypes
forEach ($contType in $contentTyps) {
if ( $contType.Name -eq 'Form' ) {
Write-Host "InfoPath Found in Library" $listTitle " at URL " $listUrl -ForegroundColor Green
}
}
}
}
else {
forEach ( $listFm in $listForms ) {
$listPath = $listFm.ServerRelativeUrl
if ( $listPath -like '*displayifs.aspx' ) {
Write-Host 'InfoPath Found in List ' $listTitle " at URL " $listUrl -ForegroundColor Green
}
}
}
}
}
}
}
}