SharePoint

SharePoint–Profile Pictures no longer show after MySite URL change

I was recently installed SharePoint 2013 and had it staged under a different hostname so that I could just migrate IP’s and create CNAME DNS records for minimal downtime. However I found that once I had everything swapped to the new server the profile photos wouldn’t work anymore and I kept getting error messages when running the User Profile Sync. The errors that showed up in the event log were from SharePoint Foundation and FIMSynchonizationService

Error: 8311 “An operating failed because the following certificate has validation errors. SSL policy error have been encountered. Error code ‘0x2’ ” – I found this issue to be related to the sync using the old URL but the web site in IIS had a different (correct) SSL certificate. Once I realized what was happening I deleted a CNAME DNS record I had “mysite2” and started getting the next error”

Error 6801: “The remote name could not be resolved: ‘mysite2.xxxxx.com’ – This is because I removed the CNAME DNS record.

 

To Fix

You need to use the trust tool Update-SPProfilePhotoStore and tell it of the change in Uri’s.

Update-SPProfilePhotoStore –MySiteHostLocation “https://mysite.xxxx.com/mysite/” -OldBaseUri "https://mysite2.xxxx.com/mysite/User Photos/Profile Pictures/" -NewBaseUri "https://mysite.xxxx.com/mysite/MySite/User Photos/Profile Pictures/"

SharePoint – Export All Documents on Site and Sub-Sites

 

I was eliminating a site on SharePoint that had over 50 sub-sites. I wanted an easy way to get all the documents in each site without having to manually visit each one. Here is an easy PowerShell script I came up with.

   1: #Created by Brandon Claps

   2: #9/25/14

   3: #Exports all documents under a specific site and sub-sites to a local directory

   4:  

   5: #Address of your SharePoint root site

   6: $MainSiteAddress = "https://sharepointsite.contoso.com"

   7:  

   8: #URL of what you you would like to gather. Type a single asterisk if you want everything

   9: $MatchURL = "*URLAddress*"

  10:  

  11: #Destination where you want to download the documents to

  12: $destination = "D:\Exported Documents"

  13:  

  14:  

  15: $Site = Get-SPSite $MainSiteAddress

  16: $WebCollection = $Site.AllWebs

  17:  

  18: foreach($Web in $WebCollection)

  19: {

  20:     foreach($List in $Web.Lists)

  21:     {

  22:         if($List.ParentWebUrl -like $MatchURL)

  23:         {

  24:             if($List.BaseTemplate -eq "DocumentLibrary")

  25:             {                                

  26:                 $webUrl = $MainSiteAddress + $List.ParentWebUrl

  27:                 $listUrl = $webUrl + "/" + $List.RootFolder.Url

  28:                 

  29:                 $web2 = Get-SPWeb -Identity $webUrl

  30:                 $list2 = $web2.GetList($listUrl)

  31:                 

  32:                 function ProcessFolder 

  33:                 {

  34:                     param($folderUrl)

  35:                     $folder = $web2.GetFolder($folderUrl)

  36:                     

  37:                     foreach ($file in $folder.Files) 

  38:                     {

  39:                         $destinationfolder = $destination + "/" + $List.ParentWebUrl.TrimStart("/").Replace("/","-") + "---" + $folder.Url 

  40:                         if (!(Test-Path -path $destinationfolder))

  41:                         {

  42:                             $dest = New-Item $destinationfolder -type directory 

  43:                         }

  44:                         

  45:                         $binary = $file.OpenBinary()

  46:                         $stream = New-Object System.IO.FileStream($destinationfolder + "/" + $file.Name), Create

  47:                         $writer = New-Object System.IO.BinaryWriter($stream)

  48:                         $writer.write($binary)

  49:                         $writer.Close()

  50:                     }

  51:                 }

  52:                 Write-Host "Downloading: " $listUrl 

  53:                 ProcessFolder($list2.RootFolder.Url)

  54:             

  55:                 foreach ($folder in $list2.Folders) {

  56:                     ProcessFolder($folder.Url)

  57:                 }                                

  58:             }        

  59:         }        

  60:     }

  61:  }