Tuesday, July 31, 2018

SharePoint TIP: working with the farm property bag


Farm Property Bag

List farm properties$farm = Get-SPFarm
$farm.Properties.GetEnumerator() | Sort Name | fl -Auto
or
(Get-SPFarm).GetEnumerator() | Sort Name | fl -Auto
Add a farm property$farm=Get-SPFarm
$farm.Properties.Add("[name]", "[value]")
$farm.Update()
Set a farm property$farm.Properties["[name]"] = $value
$farm.Update()
Remove a farm property$farm.Properties.Remove("[name]")
$farm.Update()

References

  • Properties are stored in Hash-Table (Key-Value) format.
  • Not case-sensitive.
  • Same approach is used at the web application, site collection, web and list levels.  Each of these has a "Properties" collection.  For web application properties, you would use a web application object, for site collections, get an instance of the site collection object, and so on.
  • I have found that some SharePoint solution (e.g., farm solution) providers add properties to the farm properties bag for internal sharing of licensing information.
  • Properties must be added as key-value pairs.

Friday, July 27, 2018

SharePoint 2016: Manually deploy a MasterThemes predefined them package

Introduction

This posting consolidates notes with regard to manually deploying the MasterThemes predefined theme package, 004 MTRD16 Platinum to a SharePoint Server 2016 farm.  The theme was created using SharePoint Design Manager.

Procedure

I. Deploy Core Theme Files (CSS & Images) to Farm Servers
  1. Extract the Master Themes them package file 004_MTRD16_Platinum_02_2017.zip to a convenient location.
  2. In this folder
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Core_CSS_Files\GLOBAL
    copy these files
    004_MT-Bootstrap.CSS
    004_MT-CSS.CSS
    to this folder
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\LAYOUTS\1033\STYLES\Themable
    on each of the farm's SharePoint servers.
  3. In this folder
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Core_CSS_Files\GLOBAL
    copy this entire folder
    004_MT-Images
    to this folder
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\IMAGES
    on each of the farm's SharePoint servers.
II. Deploy Theme Master Pages to Target Site Collection(s)
  1. On a local machine, open a browser and connect to the target site collection root web.
  2. At the site, navigate to this location:
    [site] > Settings > Site Settings > Web Designer Galleries > Master pages and page layouts
  3. On the ribbon, select the FILES tab, click on Upload Document, navigate to this location
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Master_Pages\GLOBAL\Core15\
    and then upload these files
    004_MT-Master-GLB.master
    004_MT-Master-GLB.preview
    Accept the default settings for each file. Once these are uploaded, click Upload Document again, navigate to this location
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Master_Pages\GLOBAL\Core15\Master Page with Footer\
    and then upload these files
    004_MT-Footer-GLB.master
    004_MT-Footer-GLB.preview
    Accept the default settings for each file.
  4. Modify each of the uploaded file settings as shown:
    Content Type:Html Master Page
    Name:004_MTRD16_Platinum
    Title:[same as Name]
    Description:[as desired]
    Compatible UI Version(s): 15
    Contact: [your alias]
    Preview Image:[not set]
    Hidden Page:[unchecked]
    Default CSS File[blank]
    Associated File: [unchecked]
    Preview URL:[blank]
    Leave all other settings as default. Note that the Approval Status of each file at this point is "Draft". 
  5. Select each of the uploaded files in turn, and then on the FILES tab of the ribbon, in the Workflows group click Publish. This changes the Approval Status of each file to "Pending". NOTE: this step may not be necessary when page Content Type is set as HTML Master page.
  6. Select each of the uploaded files in turn, and then on the FILES tab of the ribbon, in the Workflows group click Approve. This changes the Approval Status of each file to "Approved".
III. Add 004_MTRD16_Platinum Predefined Color Palettes to Site Collection Theme Gallery
  1. On a local machine, open a browser and then connect to the root web of the site collection.
  2. At the site, first navigate to this location
    [site] > Settings > Site Settings > Web Designer Galleries > Themes
    and then click on the "15" folder.
  3. On the ribbon, select the FILES tab, click on Upload Document, navigate to this location
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Theme_Gallery
    and then upload these files (there are seven of them)
    004_MT-Palette_001.spcolor
    004_MT-Palette_002.spcolor
    004_MT-Palette_003.spcolor
    004_MT-Palette_004.spcolor
    004_MT-Palette_005.spcolor
    004_MT-Palette_006.spcolor
    004_MT-Palette_007.spcolor
    NOTE: you can also drag-and-drop them as a group onto the "15" folder in the Themes document library.
IV. Configure 004_MTRD16_Platinum Composed Looks
  1. On a local machine, open a browser and then connect to the root web of the site collection.
  2. At the site, navigate to this location
    [site] > Settings > Site Settings > Web Designer Galleries > Composed looks
  3. Click "+ new item", and then enter the following for a new look:
    Title:004 MT-Palette 001
    Name:004 MT-Palette 001
    Master Page URL:/_catalogs/masterpage/004_MT-Master-GLB.master
    Type the Description/_catalogs/masterpage/004_MT-Master-GLB.master
    Theme URL/_catalogs/theme/15/004_MT-Palette_001.spcolor
    Type the Description/_catalogs/theme/15/004_MT-Palette_001.spcolor
    Image URL:[leave blank]
    Type the Description[leave blank]
    Font Scheme URL:[leave blank]
    Type the Description[leave blank]
    Display Order:310
    NOTE: the above URLs are relative to the primary site collection.  If you have sites created below this one, you will need to amend the URL appropriately.  For example, for a site at "/sites/Marketing," the Master Page URL would be "/sites/Marketing/_catalogs..."
  4. Repeat the previous step for each of the color palettes, incrementing the Title and Theme URL appropriately.
  5. At the site, navigate to this location,
    [site] > Settings > Site Settings > Web Designer Galleries > Composed looks
V. Add 004_MTRD16_Platinum Page Layouts for Publishing Sites (Optional)
  1. On a local machine, open a browser and then connect to the root web of the site collection.
  2. At the site, navigate to this location
    [site] > Settings > Site Settings > Web Designer Galleries > Master pages and page layouts
  3. On the ribbon, select the FILES tab, click on Upload Document, navigate to this location
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Layouts\Publishing_Layouts
    and then upload these files
    MT-Welcome_2Column_SBL.aspx
    MT-Welcome_2Column_SBR.aspx
    MT-Welcome_3Column.aspx
    Accept the default settings for each file.
  4. Modify each of the upload file settings as shown:
    Content Type:Page Layout
    Name:MT-Welcome_3Column
    Title:MT-Welcome_3Column
    Description:leave it blank (or provide your description)
    Contact:[your alias]
    Preview Image:Leave it blank
    Type the description:Leave it blank
    Hidden Page:Unchecked
    Associated Content Type:Page Layout Content Types
    Content Type Name:Welcome Page
    Variations:Leave it blank
    Authenticated Cache Profile:(None), or select a desired value
    Anonymous Cache Profile:(None), or select a desired value
  5. Leave all other settings as default, and then click the SAVE button.  Note that the Approval Status of each file at this point is "Draft".
  6. Select each of the uploaded files in turn, and then on the FILES tabof the ribbon, in the Workflows group click Publish.  This changes the Approval Status of each file to "Pending".
  7. Select all of the uploaded files, and then on the FILES tab of the ribbon, in the Workflows group click Approve.  This changes the Approval Status of each file to "Approved".
  8. On a local machine, open a browser and then connect to the target site collection root.
  9. At the site, navigate to this location:
    [site] > Settings > Site Content > Pages
    Add a new page, and then while in page edit mode, click on the Page Layout button on the ribbon's PAGE tab, and then verify that the three new layouts appear in the listing.
VI. Add 004_MTRD16_Platinum Pages with Predefined Content to Publishing Sites (Optional)
  1. Open the package folder, and then navigate to this subfolder:
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Layouts\Layouts_with_Content
    In this folder, copy these file.s
    MT-Publishing_Layouts.cmp
    to a SharePoint farm server (for example, I usually use the server hosting CA).  
  2. Importing this library export package deploys new pages to the Pages document library.  One of the pages that it will import is default.aspx.  Therefore, if you are using this currently as the name of your home page for the root web, you need to temporarily change it to something different before importing the pages.  Afterwards, you can rename the imported default.aspx to something different, and then rename your old home page back to default.aspx.
  3. On SPDEVCA, in an elevated SMS, execute the following commandlet to import the predefined pages to the Pages document library
    Import-SPWeb -Identity "[site url]" -Path "[path to export package]\MT-Publishing_Layouts.cmp"
  4. On a local machine, open a browser and then connect to the root web of the site collection.
  5. At the site, navigate to this location:
    [site] > Settings > Site Content > Pages
    Verify that the following new ages appear listed:
    Article---Body-Only
    Article---Image-Left
    Article---Image-Right
    Article---Summary-Links
    Blank-Web-Part-Page
    Predefined-Table-Grids
    Styles---Body-Area
    Welcome-2-Column-A
    Welcome-2-Column-B
    Welcome-2-Column-Slider
    Welcome-3-Column-A
    Welcome-3-Column-B
    Welcome-Summary-Links
VII. Add 004_MTRD16_Platinum Web Part Pages with Predefined Content to Any Site (Optional)
  1. Open the package folder, and then navigate to this subfolder:
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Layouts\Layouts_with_Content
    In this folder, copy this  file
    MT-Text_and_Webpart_Layouts.cmp
    to a folder on a SharePoint farm server (e.g., I usually use the SharePoint server hosting CA).
  2. On the server, open an elevated SharePoint Management Shell, and then execute the following commandlet to import the pages into the site's Site Pages document library:
    Import-SPWeb -Identity "[root site url]" -Path "[path to export package on server]\MT-Text_and_Webpart_Layouts.cmp"
  3. At the site, navigate to this location:
    [site] > Settings > Site Content > SitePages
    Verify that the following new ages appear listed:
    Text Layout - Page A.aspx
    Text Layout - Page B.aspx
    Text Layout - Page C.aspx
    Text Layout - Page D.aspx
    Text Layout - Page E.aspx
    Text Layout - Page F.aspx
    Text Layout - Page G.aspx
    Text Layout - Page H.aspx
    Text Layout - Page I.aspx
    Web Part Page SideBar - Left.aspx
    Web Part Page SideBar - Right.aspx
    Web Part Page Splash 3 - Column.aspx
VIII. Add 004_MTRD16_Platinum Web Parts (Optional)
  1. On a local machine, open a new instance of IE (32-bit) and then connect to the root web of the site collection
  2. At the site, navigate to this location:
    [site] > Settings > Site Settings > Web Designer Galleries > Web parts
  3. On the document library's ribbon, select the LIBRARY tab and then click Open with Explorer
  4. On your local machine, navigate to this theme package folder
    \004_MTRD16_Platinum_02_2017\004_MTRD16_Platinum_02_2017\Web_Parts
    and then copy all of these web part files
    Article_A.dwp
    Article_B.dwp
    BannerImages-ContentEditor.dwp
    BodyText-ContentEditor.dwp
    Carousel-ForFullWidthLayout.dwp
    Carousel-ForLayoutwithSidebar.dwp
    EmployeeLookup.dwp
    Hide_Side_Navigation.dwp
    Hide_Side_Navigation-No_Column_Width.dwp
    IMGLeft1Column-ContentEditor.dwp
    LatestNews-ContentEditor.dwp
    List1Col-ContentEditor.dwp
    List2Columns-ContentEditor.dwp
    ListIMGTop-ContentEditor.dwp
    MainMessage-ContentEditor.dwp
    OurServices-ContentEditor.dwp
    RequestQuote.dwp
    ServiceDesk-ContentEditor.dwp
    StandaloneHeading-ContentEditor.dwp
    SummaryLink1Column-Bulleted.webpart
    SummaryLink1Column-IMGLeft.webpart
    SummaryLink1Column-IMGLeft_B.webpart
    SummaryLink2Columns-Bulleted.webpart
    SummaryLink2Columns-IMGLeft.webpart
    SummaryLink2Columns-IMGLeft-Banded.webpart
    TableofContents-Layout_Preset.webpart
    TimeReporting-SummaryLink.webpart
    to the Web Part document library.
  5. Edit the file properties of each of the uploaded web part files in turn as follows:
    Group: 004_MTRD16_Platinum
  6. Add a new page to the Pages document library.  Open this page   in Edit mode, and then, on the PAGE tab of the ribbon, verify that the 004_MTRD16_Platinum group of web parts appears.

References

Notes

  • Installing the theme package by deploying the package's sandbox solution will remove all of the OOTB composed looks configured in the Settings > Site Settings > Web Designer Galleries > Composed looks list.  The files comprising each OOTB composed look are still there and can be used to manually re-create the OOTB composed looks if desired.