Archive for David Andrew Smith

SharePoint 2010 PowerShell Backup and Restore

I was asked to make a copy of a Site Collection on the production server and put it on the development server with the subsites and permissions intact. These steps did the trick using these scripts (thanks to Brad Schacht’s Blog for this):

Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

  • Force – Include this if you want to override a backup with the same name
  • NoSiteLock – Will prevent the site from going to Read Only mode while the backup is being taken. A small warning, if someone changes content on the site while the backup is being created and according to Microsoft “might lead to possible data corruption”
  • UseSQLSnapshot – A database snapshot will be taken before the backup begins and the backup will be done off the snapshot. The advantage is that changes can be made to the site while the backup process is running without fear of corruption. The snapshot will be deleted automatically when the backup is completed. You don’t need to specify the -NoSiteLock parameter when using this method

Restore-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-DatabaseServer DatabaseServerNameHere] [-DatabaseName ContentDatabaseNameHere] [-HostHeader HostHeaderHere] [-Force] [-GradualDelete] [-Verbose]

  • DatabaseServer – Specify the server for the content database
  • DatabaseName – Specify the name of the content database
  • HostHeader – URL of the Web application that will hold the host-named site collection
  • Force – Overwrite the site collection if it exists
  • GradualDelete – Recommended for site collections over 1 Gig in size, existing data is marked as deleted and gradually removed over time by a job rather than all at once to reduce the performance hit of deleting large amounts of data

—————————————————————————–

  1. To Backup site 
    1. Use Remote Desktop to log into production server
      1. Login with the Service Account (farm admin account that has access to content databases)
    2. Create a folder on the e: drive to put backup file
      1. (Note: it is best practice not to put backup files on the c: drive)
    3. Open ‘SharePoint 2010 Management Shell’
    4. Create backup script in Notepad, then copy and paste it in:

Backup-SPSite -Identity http://yourProductionServer/sites/yourSite
-Path e:\SiteBackups\yourSite.bak
——————————————————————————————

  1. To Restore site
    1. Use Remote Desktop to log into development server
      1. Login with the Service Account (farm admin account that has access to content databases)
    2. Create a folder on the e: drive to put backup file
    3. Copy and paste .bak file from production server Remote Desktop window (e: drive) to development server Remote Desktop window (e: drive)
    4. Open ‘SharePoint 2010 Management Shell’
    5. Create restore script in Notepad, then copy and paste it in:

Restore-SPSite “http://yourDevServer/sites/yourSite”
-Path e:\SiteBackups\yourSite.bak
—————————————————————————–

Note 1: it is best practice to run Backup and Restore scripts after hours because of the site logs, and because the site will be locked (read only) during the backup. Although there are some alternatives available, such as the [-UseSqlSnapshot] and [-NoSiteLock] paramaeters…

Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]

See the Backup-SPSite technet page for details on these parameters.

Note 2: The difference between Backup-SPSite and Export-SPWeb

  1. Workflows are included when you use the Backup_SPSite cmdlet
  2. SPSite targets Site Collection objects
  3. SPWeb targets sites (subsites), list and library objects

MOSS 2007 Document Library PDF Upload Error-File Size Issue

Problem: I have a MOSS 2007 farm (on Windows 2008 Service Pack 2) that is 5 years old, and i’ve never had problems uploading a PDF document until [Today]. My freaking Document Library wouldn’t let me upload a pdf that is 44 MB in size. The default file size limit for web applications is 50 MB. I changed the limit to 500 MB in Central Administration, but it still wouldn’t upload!

Solution: I found a couple blogs that said this is a MS bug for MOSS 2007 farms on Windows 2008, and that the solution is to add this code below to the web.config file. I did it and it worked for me.

  • Remote into WFE
  • Open IIS 7
  • Right-click on site in question (Extranet39979 in my case), click ‘Explore’
  • This will open up a window at this location: inetpub\wwwroot\wss\VirtualDirectories\Extranet39979 and you should see your web.configuration file
  •  Make copy of web.configuration file
  • Open web.configuration file in Notepad and paste this code at the end of the file after the <system.net> tags:
<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="52428800"/>
    </requestFiltering>
  </security>
</system.webServer>

 

<system.net>
    <defaultProxy>
      <proxy autoDetect="true" />
    </defaultProxy>
  </system.net>

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="52428800"/>
      </requestFiltering>
    </security>
  </system.webServer>

    <location path="_vti_bin/ReportServer/ReportServiceAuthentication.asmx">
      <system.web>
        <authorization>
          <allow users="*" />
        </authorization>
      </system.web>
    </location>
<spSolutions><dataZoom><providers /></dataZoom></spSolutions>
</configuration>

SharePoint 2010 SPD Workflow if Date is Empty

Problem 1: I need to build a SPD workflow where If ‘completed date’ is empty and ‘status’ field is ‘completed’, then fill in ‘completed date’ field with ‘modified’ field (‘when an item is created’, and ‘when an item is changed’).

Problem 2: SPD Workflows do NOT have the ‘is empty’ option on date fields. Whaaaattt?

Solution:

  • In Step 1, use the ‘Set Workflow Variable’ action to create a variable called ‘CompletionDate’. Set this variable to Current Item:Completed Date, Return field as: As String.
  • Then in Step 2 you will have a string variable that has the ‘is empty’ option …. see picture below:
  •  

 

Excel Services Stops Working – Whaaaattt?

Problem: I have a brand new SharePoint Server 2010 farm, only a few months old and up until today my Excel Services was working flawlessly. Today, however, I noticed that my dashboard pages were all displaying error messages in my Excel Access web parts. All of them displayed the pop-up error box with the message: “Unable to process the request. Wait a few minutes and try performing this operation again.”

Solution: I did an IIS Reset on my WFE and my Apps servers, and it magically fixed everything.

SharePoint 2010 Branding Options: Master Pages vs. Themes: Part 3

Adding a sticky footer to your custom master page using SharePoint Designer 2010

Adding a sticky footer to your master page is one of those basic things that takes a lot longer in SharePoint than it should. My first attempt at sticking a footer to the bottom of my page ended unsuccessfully with the footer always being about 100-200 pixels above the bottom of the page. I took a deep breath and asked my good friend Google for help. Google introduced me to Elio Struyf’s most excellent posts straight out of Belgium.

Struyf, Drisgill and other experts note that the javascript used to control scrolling in the Ribbon Positioning System (docked by default at the top of each SharePoint 2010 page) is the main culprit causing all of this footer kerfuffle. They offer advice on how to disable the Ribbon Position System (RPS) so that it is undocked, but I like having it docked. Fortunately, Struyf has a master page for the default docked ribbon (I use this one) as well as the undocked ribbon.

By adding some new div tags to the html of the master page, some new CSS, and tweaking some attributes in the V4.masterpage, Struyf has built a master page that sticks the footer to the bottom of the page while keeping the RPS docked at the top of the page.

Here are the steps and screenshots I took to add his master page to my farm:

  1. Downloaded his master page from his web site: V4.Master_Footer_Docked_Ribbon to my desktop
  2. Navigated to the Master Page Gallery in my Site Collection and uploaded the master page
  3. Opened site in SharePoint Designer 2010, and opened new master page for editing
  4. Copied and pasted the CSS from his header to my custom style sheet
  5. Added a line of code in the header to attach my custom style sheet (see Part 2 for instructions)
  6. Saved, Checked-In, Published, Approved Master Page
  7. Refresh browser to view footer (screenshot)!

Screenshot 1: V4.master Head (click image for larger view)

Screenshot 2: V4.Master_Footer_Docked_Ribbon Head (click image for larger view)

Screenshot 3: V4.master footer (no footer yet) (click image for larger view)

Screenshot 4: V4.Master_Footer_Docked_Ribbon footer (click image for larger view)

Screenshot 5: CSS from V4.Master_Footer_Docked_Ribbon (I moved this code from Elio’s master page to my custom style sheet)


Featured Series of Posts on Branding Options in SharePoint 2010:

0. SP 2010 Branding Options: Master Pages vs. Themes: Overview
Why I prefer custom master pages over custom themes in SP 2010

1. SP 2010 Branding Options: Master Pages vs. Themes: Part 1
Attaching an alternate style sheet to the master page using the browser’s UI

2. SP 2010 Branding Options: Master Pages vs. Themes: Part 2
Attaching an alternate style sheet to the master page using SPD 2010

2.1 SP 2010 Branding Options: Master Pages vs. Themes: Part 2.1
How to edit the master page to add a custom logo and a favicon with SharePoint Designer 2010

3. SP 2010 Branding Options: Master Pages vs. Themes: Part 3
Adding a footer to your custom master page using SharePoint Designer 2010

4. History of SharePoint Branding: 2007 to 2010
A tribute to Heather Solomon’s legendary blog posts on MOSS 2007 themes and master pages

5. SharePoint 2010 CSS: List of Useful Styles

SharePoint 2010 Branding Options: Master Pages vs. Themes: Part 2.1

How to edit the master page to add a custom logo and a favicon with SharePoint Designer 2010…

Favicon and Custom Logo

Favicon and Custom Logo

Follow the first few steps (1-5) in the previous post, Part 2, to open your master page and show the Code view in SharePoint Designer 2010.

Here is the code to edit the existing Favicon code in the tags (screenshot):

<SharePoint:SPShortcutIcon runat="server" IconUrl=" http://yourServer.com/images/favicon.ico"/>

There are at least 3 options to add a custom logo (Drisgill et al., pg 227):

  1. Use an HTML image tag: <img src=”customLogo.gif” alt=”Happy face”/>
  2. Use a CSS background-image property:
    .s4-title  {
    background-image:url('customLogo.gif');
    }
  3. Use the SharePoint control. I chose this option since it allows you to “set a default image for the master page that can be overridden by the SharePoint web interface from the Title, description, and icon Site Settings page (Drisgill et al., pg 227).” Here is the code I used in the Body to set the default custom logo and the link URL, and a screenshot of where I put it in the master page:

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/"                                     id="onetidProjectPropertyTitleGraphic">
<SharePoint:SiteLogoImage                                                     LogoImageUrl="http://yourServer/images/customLogo.gif" runat="server"/>
</SharePoint:SPLinkButton>

Note: I have found it easiest to keep my custom site logos, favicon, and custom CSS externally (external from the SharePoint farm) on one of our web servers. That way I can just paste in an absolute URL for the custom logo, favicon and CSS where needed, and I can go to one place to update these files. For example, after a quick update to the CSS file I just have to save it there in one place, rather than re-deploying to the various Style Libraries. I don’t like to access the SharePoint server if I don’t absolutely need to, I am superstitious that way. We are in a relatively small work environment with under 500 users and I am the main SharePoint person. We don’t do any custom coding, we have a codeless environment with no Visual Studio action for custom features or solutions to deploy this stuff for me, so this has been the best solution for me so far. What do you think, is there a better way? Here is busy blog post about putting CSS files in _layouts folder or a document library such as the Style Library: http://sharepoint.stackexchange.com/questions/2219/css-files-in-layouts-or-document-library/16253#16253


Featured Series of Posts on Branding Options in SharePoint 2010:

0. SP 2010 Branding Options: Master Pages vs. Themes: Overview
Why I prefer custom master pages over custom themes in SP 2010

1. SP 2010 Branding Options: Master Pages vs. Themes: Part 1
Attaching an alternate style sheet to the master page using the browser’s UI

2. SP 2010 Branding Options: Master Pages vs. Themes: Part 2
Attaching an alternate style sheet to the master page using SPD 2010

2.1 SP 2010 Branding Options: Master Pages vs. Themes: Part 2.1
How to edit the master page to add a custom logo and a favicon with SharePoint Designer 2010

3. SP 2010 Branding Options: Master Pages vs. Themes: Part 3
Adding a footer to your custom master page using SharePoint Designer 2010

4. History of SharePoint Branding: 2007 to 2010
A tribute to Heather Solomon’s legendary blog posts on MOSS 2007 themes and master pages

5. SharePoint 2010 CSS: List of Useful Styles