Pages

Thursday, July 25, 2019

SharePoint 2013/2016/2019 - RSS Viewer WebPart Error

When working with RSS web part in SharePoint, you get the following error:

"The requested RSS feed could not be displayed. Please verify the settings and url for this feed. If this problem persists, please contact your administrator."

The issue can be resolved by using the following commands:

  1. #This command will set the disable intranet - calls value to false.  
  2. Add - PSSnapin Microsoft.sharepoint.powershell  
  3. $farm = Get - SPFarm  
  4. $farm.Properties.DisableIntranetCalls = $false  
  5. $farm.Properties.DisableIntranetCallsFromApps = $false  
  6. $farm.Update() 

There is a code change in SharePoint 2013 & 2016, SharePoint uses a .NET call to get more information about the address and it failed because our network configuration doesn't allow the DNS resolution of an internet address as well as we are not using the host file entries.
  1. System.Net.Dns.GetHostAddresses(System.String)  
Thus, if DisableIntranetCalls is set to true (default), then use .NET call given above to confirm the DNS. However, if DisableIntranetCalls is set to false, then SharePoint will not make this call and use other code to reach the site.

Tuesday, September 25, 2018

SharePoint Migration: Farm Checked Out Files Report

During SharePoint migration, it is helpful to review checked out files that have never been published or files that were checked out but were never checked in by end users. If you are using a SharePoint migration tool for e.g.; Sharegate or Metalogix Content Matrix, these checked out files will not be migrated. The script generates a report of the checked out files on the sub-site level and will come handy to prepare for the migration. You can provide this report to site owners so that they can take action on it. :)

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

$date = Get-Date -f 'yyyyMMdd-hhmmss'
$curDirectory = (Get-Item -Path ".\").FullName

if( -Not (Test-Path -Path $curDirectory"\Output" ) )
{
    New-Item -ItemType directory -Path $curDirectory"\Output"
}

$Output = $curDirectory + '\Output\FarmCheckedoutFilesReport_'+$date+".csv"

function GetCheckedOutItems($spWeb)
{
Write-Host "Scanning Site: $($spWeb.Url)"
foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
    Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)"
    foreach ($item in $list.CheckedOutFiles) {
       
        $itemURL = $spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)")
        #Uncomment the following for debugging
        #Write-Host $itemURL
        #Write-Host "Author: $($item.File.ModifiedBy)"
        #Write-Host "Author: $($item["Editor"].Split('#')[1])"
        #Write-Host "Name: $($item.CheckedOutByName)"
        #Write-Host "Email: $($item.CheckedOutByEmail)"
        #Write-Host "Checked Out Date: $($item.TimeLastModified)"
        #Read-Host
            

        Add-Content $output -Value """$($spWeb.Url)"",""$($list.RootFolder.ServerRelativeUrl)"",""$itemURL"",""$($item.CheckedOutByName)"",""$($item.CheckedOutByEmail)"",$($item.Length/1000),""$($item.TimeLastModified.ToString())"","""","""",Never Checked In"
       
    }
    foreach ($item in $list.Items) {
        if ($item.File.CheckOutStatus -ne "None") {
         $itemURL = $spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)")
            if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
            Add-Content $output -Value """$($spWeb.Url)"",""$($list.RootFolder.ServerRelativeUrl)"",""$itemURL"",""$($item.File.CheckedOutByUser.Name)"",""$($item.File.CheckedOutByUser.Email)"",$($item.File.Length/1000),""$($item.File.CheckedOutDate.ToString())"",""$($item["Author"].Split('#')[1])"",""$($item["Editor"].Split('#')[1])"",Checked Out"
            #Uncomment the following for debugging
            #Write-Host $itemURL
            # Write-Host "Author: $($item["Author"].Split('#')[1])"
            # Write-Host "Author: $($item["Editor"].Split('#')[1])"
            #Write-Host "CheckedOutBy: $($item.File.CheckedOutByUser)"
            #Write-Host "Name: $($item.File.CheckedOutByUser.Name)"
            #Write-Host "Email: $($item.File.CheckedOutByUser.Email)"
            #Write-Host "Checked Out Date: $($item.File.CheckedOutDate.ToString())"
            #Read-Host
            
        }
    }
}

$spWeb.Dispose()
}


Add-Content $output -Value "SiteURL,DocumentLibrary,FileURL,CheckedOutBy,CheckedOutByUserEmail,FileSize,CheckedOutSince,Author,Editor,Check In Status"

$webApp = Get-SPWebApplication 
foreach($webapps in $webapp)
{

    foreach ($SiteCollection in $webApps.Sites)
    {
     if ($SiteCollection.ReadOnly -eq $false -and $SiteCollection.ReadLocked -eq $false -and $SiteCollection.WriteLocked -eq $false) 
        {
             $weburl = $SiteCollection.OpenWeb()

              foreach($web in $SiteCollection.AlLWebs)
              {
                GetCheckedOutItems($Web)
                $web.Dispose()
              }
        }
    }
}

Write-Host "Processing completed. Please see the report at $($Output)."