$applyChanges = $false; $testPass = $true; $documentTemplateUrl = "Library/Forms/template.xsn" $web = Get-SPWeb http://Server/Sites/Site if ($web -eq $null) { "web not found"; return; } $listName = "Library"; $list = $web.Lists[$listName] if ($list -eq $null) { "List $listName not found"; return; } $newTemplateUrl = [Microsoft.SharePoint.Utilities.SPHttpUtility]::UrlPathEncode($web.Site.MakeFullUrl($documentTemplateUrl), $true); Write-Host "Content Type document template url = " $newTemplateUrl; $spQuery = New-Object Microsoft.SharePoint.SPQuery $spQuery.ViewAttributes = "Scope='Recursive'"; $spQuery.RowLimit = 500 $caml = '' $spQuery.Query = $caml do { "Getting item batch" $listItems = $list.GetItems($spQuery) $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition foreach ($item in $listItems) { Write-Host "Item ID = " $item["ID"]; if ($item["TemplateUrl"] -ne $newTemplateUrl) { $oldurl = $item["TemplateUrl"] $item["TemplateUrl"] = $newTemplateUrl; if ($applyChanges -eq $true) { Write-Host "Changing " $oldurl " to " $item["TemplateUrl"] $item.SystemUpdate(); } else { Write-Host "Would change " $oldurl " to " $item["TemplateUrl"] } } } if ($testPass -eq $true) { "Test pass complete"; break; } } while ($spQuery.ListItemCollectionPosition -ne $null)