Category Archives: SharePoint

SharePoint 2013 – Delete User Profile PictureURL values from all profiles


SharePoint offers 3 options for User Profile and Property synchronization.

1. SharePoint Profile Synchronization
2. SharePoint Active Directory Import
3. External Identity Manager

I won’t go into the depth of each, but let’s say you choose SharePoint Profile Synchronization to import Active Directory information including the Picture.

Now after syncronization, you need to run this SharePoint Powershell to convert the imported pictures into the small, medium, large sized photos that can be used properly.


Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation http://mysitehost:port/sites/people/

Now, it seems maybe not all PictureURL properties got imported and converted, and you have to start again.

Instead of deleting the user profiles (and potential data entered by the user), here is a quick and easy way to clear out the PictureURL property from all user profiles.


Add-PSSnapin Microsoft.Sharepoint.Powershell
$site = Get-SPSite http://mysitehost:port/
$context = Get-SPServiceContext $site
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$upPictureURLAttribute = "PictureURL"
$profiles = $upm.GetEnumerator()
foreach ($userprofile in $profiles)
{
write-host "Deleting ", $userprofile[$upPictureURLAttribute].GetValue()
$userprofile[$upPictureURLAttribute].clear()
$userprofile.commit()
write-host "Deleted"
}

Advertisements

Post Migration – This page is not using a valid page layout


In case of publishing sites, when you export and import sites, the pages will throw “This page is not using a valid page layout” error.
This is due to the fact that PublishingPageLayout is hardcoded within the page itself and must be updated on the migrated site. If you want to investigate further, download the page and check for the value.

In my case, I was restoring a site collection (http://sharepoint/sites/ASITE/) as a subsite (http://sharepoint/ASITE/)using powershell (syntax below for example).

Export-SPWeb -Identity http://sharepoint/sites/ASITE/ -Path C:\Temp\ASITE.01.bak -IncludeUserSecurity -IncludeVersions All
Import-spweb -Identity http://sharepoint/ASITE/ -Path C:\Temp\ASITE.01.bak -IncludeUserSecurity -ActivateSolutions

The site http://sharepoint/sites/ASITE/ would work fine but this error would be at http://sharepoint/ASITE/

The PageLayout needs to be updated for all pages in the new site. There are many posts about doing this via powershell, and here is how mine looked like. Update the “WelcomeLinks” to suit your needs.

$spWeb = Get-SPWeb -Identity "http://sharepoint/ASITE/"
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
$pages = $spPubWeb.PagesList
foreach($item in $pages.Items)
{
$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
$url = new-object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString())
if($url -ne $null)
{
$itemPage =$url.Url
write-host $itemPage
if($itemPage -match'WelcomeLinks')
{
$newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://sharepoint/_catalogs/masterpage/WelcomeLinks.aspx, Welcome page with summary links")
$pubPage.Name
$pubPage.CheckOut()
$pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
$pubPage.ListItem.UpdateOverwriteVersion()
$pubPage.ListItem.File.CheckIn("Fixed PageLayout URL", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
}
}
}

SharePoint Calendar Overlay AND Filtering


Scenario

You have upto 10 calendars that need to be “overlayed” as one single calendar. Pretty easy – create a new Calendar and simply use the “Calendars Overlay” to get the other 10 calendars.

What if only certain items were to be filtered for, and displayed in the top Overlay Calendar?

Calendar Overlay

Easy 

  1. Create views for the individual calendars, based on the “Calendar” view, apply filters as necessary – this is a new View
  2. Goto the top “Overlay Calendar” and edit the child calendar to show the newly created view

SharePoint 24 Hour Calendar Display


The default SharePoint Calendar Day / Week view will not show a 24 hour calendar display. You will need to change the Site Regional Settings for this change to take place.

Using Powershell

$web = "http://sp/"
$spSite = [Microsoft.SharePoint.SPSite]($web)
$spWeb = $spSite.OpenWeb()
$spWeb.RegionalSettings.WorkDayStartHour = 360
$spWeb.RegionalSettings.WorkDayEndHour = 1080
$spWeb.Update()

The values for WorkDayStartHour and WorkDayEndHour are expressed in minutes from 12:00 AM

6AM = 6 x 60 = 360
6PM = 18 x 60 = 1080

Using GUI

Site > Site Settings > Regional Settings : Define Your Work Week

Disappearing Domain Accounts when adding Domain Account as Local Administrators


Story – Creating a new local lab environment using VMware Workstation for Guest OS Windows Server 2008 R2 with SP1.

I created a Domain Controller SERVER-A and created some domain service accounts (svc-A) that were to be used as Administrators on member servers.

After attaching a new guest SERVER-B as a domain computer, I tried adding the svc-A account under the local administrators group. It would let me add the account, but as soon as I added (and applied), the svc-A account would disappear from the local Administrators group.

OK.

So I try to add that account again – and – error – “Account svc-A is already a member of this group”

Culprit – my sysprep process. For Windows Server 2008 R2, I did not check the “Generalize” option, and that would not create a new SID for the member server.

I had to check the “Generalize” option, which then creates a new SID, which then allows me to add and view a domain account under local administrators for that member server.

declarative workflow does not start automatically for new item or item changed


See this http://support.microsoft.com/kb/947284

If you create a workflow to start automatically on creation of a new item or a change in the item – it may not start if the following conditions are true:

  1. The Windows SharePoint Services Web application runs under a user’s domain account.
  2. The user logs in by using this domain account.
  3. The site displays the user name as System Account.

A change to the service accounts is required – or you need to login as another user.

Typically you will face this in your individual development environment as you are most likely using one account for everything.

powershell : create list + add columns + set new default view


Had to create custom list using powershell + add columns + create a new view + set that as a default view. For the longest time, the default view just would not be set – no errors, till it dawned that I need to update the view once it is set to default (and not just update the list).

I could also not find a relevant example to add declared columns to a new view (within msdn or google), so including that as well. Check the two lines in bold below.

Here is an example:


#
$webURL = “http://spurl/site/”
$spSite = [Microsoft.SharePoint.SPSite]($webURL)
$spWeb = $spSite.OpenWeb()
#
# Create a custom list (ID is 100)
$myListGuid = $spWeb.Lists.Add(“CustInfo”, “Customer Information for Northern Projects”, 100)
$myList = $spweb.Lists[$myListGuid]
#
# Update the List Title
$myListObj = $spWeb.Lists[“CustInfo”]
$myListObj.Title = “Customer Information”
$myListObj.Update()
#
# Adding fields
$myFieldCustomerName = $myList.Fields.Add(“CustomerName”, “Text”, 0)
$myList.Fields[$myFieldCustomerName].Title = “Customer Name”
$myList.Fields[$myFieldCustomerName].Update()
#
# Adding fields
$myFieldCustomerAvailable = $myList.Fields.Add(“CustomerAvailable”, “Boolean”, 0)
$myList.Fields[$myFieldCustomerAvailable].Title = “Customer Available”
$myList.Fields[$myFieldCustomerAvailable].Update()
#
# Adding fields
$myFieldCustomerDate = $myList.Fields.Add(“CustomerDate”, “DateTime”, 0)
$myList.Fields[$myFieldCustomerDate].Title = “Customer Date”
$myList.Fields[$myFieldCustomerDate].DisplayFormat = “DateOnly”
$myList.Fields[$myFieldCustomerDate].Update()
#
# Setting the Query for the View
$viewQuery = “<OrderBy><FieldRef Name=””Modified”” Ascending=””False”” /></OrderBy>”
#
# Adding fields to the view
$viewFields = New-Object System.Collections.Specialized.StringCollection
$viewFields.Add(“Attachments”)
$viewFields.Add(“LinkTitle”)
$viewFields.Add($myFieldCustomerName)
$viewFields.Add($myFieldCustomerDate)
#
# View Name
$viewName = “view_name_here”
#
# Finally – Provisioning the View
$myListView = $myList.Views.Add($viewName, $viewFields, $viewQuery, 100, $True, $False, “HTML”, $False)
#
# You need to Update the View for changes made to the view
# Updating the List is not enough
$myListView.DefaultView = $True
$myListView.Update()
#
$myList.OnQuickLaunch = $True
$myList.Update()
#
$spWeb.Dispose()
$spSite.Dispose()