1

Can somebody help me to determine all the sites which have content editor web parts active on the SharePoint Farm? Both publishing and non publishing sites. Is there a script?

I found one at Finding CEWP’s with script in your SharePoint sites. But this one is not giving me the complete list. I guess it is only listing out the publishing sites

0

The script is returning results from both publishing sites and other sites. But it only returns CEWP's which have script tags in it or CEWP's which has a contentlink that point to a textfile with scripts. If you want all CEWP's, you need to adapt the Get-CEWP function. Replace the following code:

if ($webPart.ContentLink.Length -gt 0)
{
    # Check file in ContentLink for script tags
    $file = $web.GetFile($webPart.ContentLink)
    $data = $file.OpenBinary()
    $encode = New-Object System.Text.ASCIIEncoding
    $contents = $encode.GetString($data)
    if ($contents.ToLower().Contains("<script>"))
    {
        Write-Output "$($web.Url)/$url (CONTENTLINK)"
    }
    break
}
if ($webPart.Content.InnerText.Contains("<script>"))
{
    Write-Output "$($web.Url)/$url (HTML)"
}

with:

Write-Output "$($web.Url)/$url"

Then the function will return all CEWP webparts and not only those with script in them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.