Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jchable/26b5161dedc4bb42ab2b8bc7563e7ed0 to your computer and use it in GitHub Desktop.

Select an option

Save jchable/26b5161dedc4bb42ab2b8bc7563e7ed0 to your computer and use it in GitHub Desktop.
$web = get-spweb "<web site URL>"
function removeCustomInfopathListForms([String]$folderName, [Microsoft.SharePoint.SPContentType]$ct)
{
write-host Removing custom Infopath list form on $folderName
# Remove InfoPath customisatin
$ct.ResourceFolder.Properties["_ipfs_infopathenabled"] = "False"
# Reset default form URL
$ct.NewFormUrl = ""
$ct.EditFormUrl = ""
$ct.DisplayFormUrl = ""
$ct.ResourceFolder.Update()
write-host "Liste:" $list.Title " CT:" $strContentType
$folder = $web.getFolder($folderName)
write-host Delete files from folder: $folder.Name
# "Delete the InfoPath Form from the server"
for ($i = $folder.Files.count -1; $i -gt -1; $i--)
{
write-host deleting $folder.Files[$i].Name
$folder.Files[$i].delete()
}
$web.dispose()
}
# Check content type in all lists for InfoPath forms
foreach($list in $web.Lists) {
foreach ($ct in $list.ContentTypes){
if ($ct.ResourceFolder.Properties["_ipfs_infopathenabled"] -eq "True"){
$strfolderName =$web.url + "/" + $ct.ResourceFolder.URL
write-host "The following url is using a custom infopath list form:" $strFolderName
removeCustomInfopathListForms -folderName $strfolderName -ct $ct
}
}
}
$web.Dispose()
write-host "Script ended"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment