Sep 05

SharePoint script to change the Masterpage on all Subwebs on a Site Collection

Here is a simple PowerShell script to change the masterback back to the default masterpage in SharePoint 2010. This script will also work for SharePoint 2013. But, if you are going to change the masterpage back to the default masterpage in SharePoint 2013, change v4.master to seattle.master or whichever masterpage you need to have you sites set to. Copy the below code and paste it into Notepad or PowerShell ISE editor. Then save the file as a .ps1

Add-pssnapin Microsoft.SharePoint.Powershell -ErrorAction silentlycontinue

$WebInput = Read-Host "Please enter the site URL"

$site = Get-SPSite $WebInput

foreach ($web in $site.AllWebs)

{

$SetServerRelativeUrl = $web.ServerRelativeUrl + "/_catalogs/masterpage/v4.master"

Write-Host "Setting MasterUrl for " $web.Url "from "$web.MasterUrl " to" $SetServerRelativeUrl

$web.MasterUrl = $SetServerRelativeUrl

if ($web.MasterUrl -eq $SetServerRelativeUrl)

{

Write-Host "MasterURL Update Completed Successfully" -ForegroundColor Green

}

elseif ($web.MasterUrl -ne $SetServerRelativeUrl)

{

Write-Host "MasterURL Update Did Not Complete Successfully" -ForegroundColor Red

}

Write-Host "Setting CustomMasterUrl for " $web.Url "from "$web.CustomMasterUrl " to" $SetServerRelativeUrl

$web.CustomMasterUrl = $SetServerRelativeUrl

if ($web.CustomMasterUrl -eq $SetServerRelativeUrl)

{

Write-Host "CustomMasterUrl Update Completed Successfully" -ForegroundColor Green

}

elseif ($web.CustomMasterUrl -ne $SetServerRelativeUrl)

{

Write-Host "CustomMasterUrl Update Did Not Complete Successfully" -ForegroundColor Red

}

$web.Update()

$web.Dispose()

}

Dec 05

SharePoint 2013 with Outlook 2013 Sync issues causing the 0x80040102 error

Today I had an issue with a SharePoint 2013 farm that is in a Hyper-V environment. When trying to sync a tasks list in Outlook I would get the following error message:

“Task ‘SharePoint’ reported error (0x80040102) : ‘Outlook cannot connect to the SharePoint List (TaskListTest – Tasks). The server may not be reachable from your location. Contact the SharePoint site administrator for more information. HTTP 0.’”

To resolve the issue I had to do the following:

The NIC in the Hyper-V environment only had intranet access. I had to enable the other NIC to allow internet access. Once done the issue was resolved.

Dec 05

SharePoint 2010 and 2013 – How to output each field in a web

The below PowerShell script will cycle through the entire SharePoint web for the specified URL and will output the field title and ID:

$web = Get-SPWeb http://contoso

foreach ($field in $web.Fields)
{
write-output "Title: $($field.Title) | ID: $($field.Id)"
}
$web.Dispose()

Dec 05

Unable to create publishing pages in the pages library in SharePoint 2010 – An unexpected error has occurred

Reproduction Steps:

1) Browse to: https://contoso.com/site/myteam
2) site Actions
3) View All Site Content
4) Pages
5) Library Tools > Documents
6) New Document
7) Page
8) Get an error message saying:

An unexpected error has occurred.
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: 5a3ab0c7-9b95-4c20-a5a7-04637fe0a120
Date and Time: 2013/12/04 04:19:04 PM

When you pull the ULS logs you see:

Microsoft.SharePoint.Publishing.InvalidPublishingWebException: The site is not valid. The ‘Pages’ document library is missing.
at Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingListWithCleanup(PublishingListType list, Boolean throwExceptionOnInvalidWeb)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.get_PageListRoot()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.SetParentUrlLabel()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.LoadValues()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.CreatePagePage.LoadValues()
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.OnLoad(EventArgs e)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.CreatePagePage.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Resolution:

Get customer permission to disable publishing at the Site and Web level then run the following:

Disable-SPFeature –identity “publishingweb” -URL “https://contoso.com/site/myteam” -force
Disable-SPFeature –identity “PublishingLayouts” -URL “https://contoso.com/site/myteam” -force
Disable-SPFeature –identity “Publishing” -URL “https://contoso.com/site/myteam” -force
Disable-SPFeature –identity “PublishingResources” -URL “https://contoso.com/site/myteam” -force
Disable-SPFeature –identity “publishingSite” -URL “https://contoso.com/site/myteam” -force

Confirm that publishing is not active on the Site Collection or Site Level through the UI.

Next we need to allow the Pages library to be deleted by running the following PowerShell script:

$web = Get-SPWeb “https://contoso.com/site/myteam”
$list = $web.Lists[“Pages”]
$list.AllowDeletion = $True
$list.Update()

View All Site Content > Pages > Library Settings > Delete this document library

$web = Get-SPWeb “https://contoso.com/site/myteam”
$list = $web.Lists[“Images”]
$list.AllowDeletion = $True
$list.Update()

View All Site Content > Images> Library Settings > Delete this document library

Enable-SPFeature –identity “publishingSite” -URL “https://contoso.com/site/myteam” -force
Enable-SPFeature –identity “PublishingResources” -URL “https://contoso.com/site/myteam” -force
Enable-SPFeature –identity “Publishing” -URL “https://contoso.com/site/myteam” -force
Enable-SPFeature –identity “PublishingLayouts” -URL “https://contoso.com/site/myteam” -force
Enable-SPFeature –identity “publishingweb” -URL “https://contoso.com/site/myteam” -force

Confirm the issue is now resolved by trying to create a publishing page in the Pages library.

Oct 03

How to find a users e-mail address on a SharePoint Site

By running the following Powershell script will output the e-mail address for a user that you specify:

 


$site = get-spsite <URL>
$web = $site.rootweb
$user = $web.ensureuser("CONTOSO\User")
$user.email

Aug 01

How to tell when a Site Collection was created in SharePoint

There is a handy PowerShell command that you can use to tell when a SharePoint Site Collection was created. Open the SharePoint Management Shell and type the following:

$s = get-spsite
$s.RootWeb.Created.ToString()

Once done, you will see the date and time stamp on when the Site Collection was created.

Jan 29

Integrate SharePoint Online 2010 with CRM Online

Here are the steps to integrate SharePoint Online and CRM Online:

1. If you don’t already have a CRM Online account you can get a free 30 day trial here: http://crm.dynamics.com/en-us/trial-overview

2. When I signed up for the trial my CRM Online account URL looked like this: https://crmnaorg77a3f.crm.dynamics.com/

3. Once the trial has been setup, you will receive an e-mail saying: “Your Subscription is Ready!”

4. Download the Microsoft Dynamics CRM 2011 List Component for SharePoint 2010 located here: http://www.microsoft.com/en-us/download/details.aspx?id=5283

5. Extract “crmlistcomponent.wsp” from the file you just downloaded

6. The “AllowHtcExtn.ps1” is the PowerShell script to run for on-premis environments to allow the .htc file extension to the list of allowed file types. You can just ignore this file since we are working with SharePoint Online

7. Upload “crmlistcomponent.wsp” to your SharePoint Online Site Collection

a. Login to your Office 365 SharePoint Site Collection

b. Click “Site Actions”

c. Click “Site Settings”

d. Under the “Galleries” heading click on “Solutions”

e. Under the “Solutions” tab at the top, click on “Upload Solution”

f. Click “Browse” and find the “crmlistcomponent.wsp” file

g. Once the wsp file has been uploaded click on the “Activate” button

h. Now we will configure the CRM Online settings

i. Login to your CRM Online account

j. Click “Settings” at the bottom left side of the screen

k. Under “System” click on “Document Management”

l. Click on “Document Management Settings”

m. Select the entities you want to enable document management on

n. Enter your SharePoint Online URL into the text box

o. Click on “Next”

h. You should get a message that says your URL is a valid URL

p. Select your folder structure and click “Next”. I left the check box un-checked for my environment.

q. Once all of the Document Libraries are created click “Finish”

r. The final test

s. In CRM Online, I click on “Workplace” on the bottom left side of the screen

t. Click on “Accounts”

u. Click on the “New” button on the ribbon bar

v. I typed in an Account Name and clicked on the “Save” button

w. Next, click on “Documents” on the left side of the screen

x. You will get a pop-up message saying: “A folder will be created in the location: https://companyname.sharepoint.com/account/ “

z. Click OK to continue

8. You will now be able to browse to that location in SharePoint Online and see the folder that corresponds to the account you just created.

Jan 23

SharePoint 2010 Bulk Check-In Documents

If you have multiple checked-out files in a document library it can be painful to have to go through each document individually to check-in the document. Below are the steps to bulk check-in documents in a document library by using content and structure.

1. Site Actions
2. Site Settings
3. Under “Site Collection Administration” click on “Site collection features”
4. Activate feature “SharePoint Server Publishing Infrastructure”
5. Click Site Actions
6. Click Site settings
7. Under “Site Administration” click on “Content and structure”
8. In the left navigation pane, select the folder that contains the documents that you want to check in
9. Select all the documents that you want to check in
10. Under “Actions” select either “Discard Check Out” or ”Check In”

Jan 23

SharePoint 2010 Removing the Search Box from the Master Page

Here is how to remove the Out of Box Search box from your page layout in SharePoint 2010.

If you do not want to include the Out of Box Search box on your SharePoint Site, this can be removed by editing the Master Page and removing the Content Place Holders. You will need to have SharePoint Designer 2010 installed to complete these steps:

 

  1. Open SharePoint Designer 2010
  2. Enter the URL for your SharePoint Site
  3. Select “Master Pages” on the left side of the screen
  4. Right click on your master page and select “Edit file in Advanced Mode”
  5. Select the “Code” view on the bottom of the screen
  6. Click the “Edit” tab and click on the “Find” button on the ribbon bar
  7. Type in “search” in text box. This should bring you right to the Content Place Holder
  8. Remove the following Content Place Holder:
    <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
    <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4"/>
    </asp:ContentPlaceHolder>
  9. Save the master page
  10. Browse to your SharePoint Site and you will notice that the Out of Box Search box is gone

[warning]You should back up the Master Page in case something goes wrong![/warning]

Older posts «