SharePoint 2010 Wake Up Script as a Scheduled Task

So an Executive VP or Manager is the first person in the office in the morning, and ask you "Why is the intranet so slow every the morning?"

Well, IIS recycles daily at about 2:00am each night. This means that the first user request to access any SharePoint 2010 site will have to wait until the site "warms up" or "wakes up" before loading the page.

Lets change that! Below is a handy Powershell script that will query each top level site collection and send a request to the site. Lets take this Powershell script and combine it with a Windows scheduled task on the SharePoint web front end server(s). Lets start with the script:

//--Powershell Script Begin--

Add-PSSnapin Microsoft.SharePoint.PowerShell;

function Get-WebPage([string]$url)
{
$wc = new-object net.webclient;
$wc.credentials = [System.Net.CredentialCache]::DefaultCredentials;
$pageContents = $wc.DownloadString($url);
$wc.Dispose();
return $pageContents;
}

Get-SPAlternateUrl -Zone Default | foreach-object {
write-host $_.IncomingUrl;
$html = Get-WebPage -url $_.IncomingUrl;
}
//--Powershell Script End--

Step by Step Configuration

  1. Copy the Powershell script text above and save it as SharePointSiteWakeUp.ps1 on each of your SharePoint 2010 Web front end servers. Save the file in the "C:\Windows\" directory. 
  2. Next we will schedule a Windows Scheduled Task to run the Powershell script daily at 5:00am. (You can specify anytime after 2:15am).
  3. On your SharePoint 2010 Web Front End server(s), click 'Start' > 'Administrative Tools' > 'Task Scheduler' as shown below:   
  4. Next, Right click on 'Task Scheduler' and click 'Create Basic Task' as show below:                                                    
  5. Enter a Name for the Task and click 'Next'
  6. Set the Task Frequency to Daily and click 'Next'
  7. Set the scheduled daily Start time to 5:00 AM every 1 day and click 'Next'
  8. Choose the Action 'Start a Program' and click 'Next'
  9. Next, in the 'program/script' text box enter the following: powershell -file "C:\Windows\SharePointSiteWakeUp.ps1" then click 'Next': 
  10. You will receive a message that arguments have been included in the Program text box. Click 'Yes' to continue:                                        
  11. Review the Task Summary and click 'Finish' to complete the wizard: 

That is it! Now when the first user of the day goes to open a SharePoint site, it will respond in just 1-3 seconds instead of 30-45 seconds.

SQL Log File Cannot be Truncated or Shrunk Explained

Let's start by saying, this was a HUGE pain in the rear. So a client of mine is running SQL Server 2008 behind their SharePoint 2007 environment (this would also apply to SharePoint 2010), and one of the databases is 420MB's, but the Log File is 103GB's!!!

Wow, great catch, guess I will just set the recovery mode to Simple, and shrink the Log file right?
Wrong, its not that easy...

After about 2 days of research and sql queries, I ran into an MSDN article that explains where to look for the specific issue and resolve. Here are the steps I followed:


--Begin SQL commands--

--This command showed me the database was stuck in ‘REPLICATION’
SELECT name, log_reuse_wait_desc FROM sys.databases

--This command below removed the database from being stuck in ‘REPLICATION’ which should no unlock the database for maintenance/shrinking:
EXEC sp_removedbreplication SharedServices1_DB

--The following command shrinks the log file and sets the recovery mode back to Full.
USE SharedServices1_DB;

-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (2, 1);  -- here 2 is the file ID for trasaction log file,you can also mention the log file name (dbname_log)
GO

-- Reset the database recovery model.
ALTER DATABASE SharedServices1_DB
SET RECOVERY FULL;
GO

The end result, we have a healthy database, that is only 420mb’s and the log file is 1MB!

GUID URL Decoder/Encoder is Great!

I came across a very useful tool which will take an ugly, un-encoded GUID and automatically add the fancy stuff aka put it into a useful format. See the example below:

Original GUID: %7BDHJTY8B%2DJGU5%2D8FE6%2DAY38E%2D5DTU58F9L5DB%7D
Decoded GUID: {DHJTY8B-JGU5-8FE6-AY38E-5DTU58F9L5DB}

Check out the tool here: http://meyerweb.com/eric/tools/dencoder/

Fix Broken Alerts After a SharePoint 2007 to 2010 Migration

So after performing a DB attach upgrade for a client, I found that all the Alerts they had setup were broken.
Well, hello PowerShell, can you help me? (That's a silly question).

The following is a script I used via SharePoint Management Shell as an Administrator to retrieve a list of alerts for the entire Site collection: http://portalnew


Get Alerts for site collection:
Get-SPweb -site http://portalnew -limit all | ForEach-Object {$_.alerts|foreach-object{write-host $_.user $_.properties["siteUrl"] $_.properties["dispformurl"]}}

After performing the above script, I saw a handful of alerts looking for the old server name. The below script updates the server name for all alerts needing the update:

Update URL for broken alerts:
Get-SPweb -site http://portalnew -limit all | ForEach-Object {$_.alerts|foreach-object{$_.properties["siteUrl"] = "http://portalnew";$_.update()}}

Have fun with that!

How To: SharePoint 2007 Multiple File Check In / Check Out


So you uploaded a handful (or a few hundred) files to SharePoint 2007 and can't find a way to do a mass check-in for the documents. This tutorial will show you how to avoid checking in these files one at a time using the Manage Content and Structure Feature.
It is a very easy to use browser interface that allows you to move items and yes, check in and out multiple documents. To get to this feature we will use the Site Actions Menu. 
Please note you must have the proper permissions (contribution at least) and you will not see all the options from the screen shots below if you do not have full control to the Site Collection.
  1. Open the SharePoint Site. The Site Actions button is in the top right hand corner. Click 'Site Actions and Manage Content and Structure'.SharePoint File Check In or Out Step 1
  2. Navigate to the Document Library and folder containing the documents you wish to check in and click on it to expose the documents to the right.SharePoint Multiple File Check In or Out Step 2
  3. Now if you haven’t seen this check box before it simply selects all the boxes in the view. Click this select all in view or simply check the ones you need to check in or out.SharePoint Multiple File Check In or Out Step 3
  4. Highlights your selectionsSharePoint Multiple File Check In or Out Step 3-b
  5. Now using the Actions Menu select Check In or Out depending on your taskSharePoint Multiple File Check In or Out Step 4
Now you have successfully checked in or out multiple documents!

SharePoint 2010 Versions


Microsoft SharePoint Server 2010

Release Version KB
RTM 14.0.4762.1000 n/a
June 2010 CU 14.0.5114.5003 n/a
Aug 2010 CU 14.0.5123.5000 2352342
Oct 2010 CU 14.0.5128.2003 2394320
Dec 2010 CU 14.0.5130.5002 2459257
Feb 2011 CU 14.0.5136.5002 2475878
April 2011 CU 14.0.5138.5001 2512800
Service Pack 1 14.0.6029.1000 2460045

June 2011 CU (Refresh) 14.0.6106.5002 2536599
August 2011 CU 14.0.6109.5002 2553048
October 2011 CU 14.0.6112.5000 2596505
December 2011 CU
February 2012 CU
14.0.6114.5000
14.0.6117.5002
2597014
2597150

SharePoint 2010 List of Templates

Some may find this handy, especially when all you have is a GUID in your error log. Use this list to reference the Feature ID (GUID) and/or Template ID of specific SharePoint Lists.

Description Feature Id Template Type Id
Generic List 00BFEA71-DE22-43B2-A848-C05709900100 100
Document Library 00BFEA71-E717-4E80-AA17-D0C71B360101 101
Survey List 00BFEA71-EB8A-40B1-80C7-506BE7590102 102
Links List 00BFEA71-2062-426C-90BF-714C59600103 103
Announcements List 00BFEA71-D1CE-42de-9C63-A44004CE0104 104
Contacts List 00BFEA71-7E6D-4186-9BA8-C047AC750105 105
Events List 00BFEA71-EC85-4903-972D-EBE475780106 106
Tasks List 00BFEA71-A83E-497E-9BA0-7A5C597D0107 107
Discussion Board 00BFEA71-6A49-43FA-B535-D15C05500108 108
Picture Library 00BFEA71-52D4-45B3-B544-B1C71B620109 109
DataSources List 00BFEA71-F381-423D-B9D1-DA7A54C50110 110
WebTemplate Catalog   111
UserInformationList   112
ListTemplate Catalog   114
WebPart Catalog   113
XmlForm Library 00BFEA71-1E1D-4562-B56A-F05371BB0115 115
MasterPage Catalog   116
NoCode Workflows 00BFEA71-F600-43F6-A895-40C0DE7B0117 117
Workflow Process 00BFEA71-2D77-4A75-9FCA-76516689E21A 118
WikiPage Library 00BFEA71-C796-4402-9F2F-0EB9A6E71B18 119
Grid List 00BFEA71-3A1D-41D3-A0EE-651D11570120 120
SolutionCatalog   121
NoCode Workflows Public 00BFEA71-F600-43F6-A895-40C0DE7B0117 122
Theme Catalog   123
DataConnection Library 00BFEA71-DBD7-4F72-B8CB-DA7AC0440130 130
Workflow History 00BFEA71-4EA5-48D4-A4AD-305CF7030140 140
Gantt Tasks 00BFEA71-513D-4CA0-96C2-6A47775C0119 150
Help Library 071DE60D-4B02-4076-B001-B456E93146FE 151
Meetings List   200
MeetingAgenda List   201
MeetingAttendees List   202
MeetingDecision List   204
MeetingObjectives List   207
MeetingTextBox   210
MeetingThingsToBring List   211
MeetingHomePage Library   212
BlogPosts List   301
BlogComments List   302
BlogCategories List   303
ScheduleAndReservations 636287a7-7f62-4a6e-9fcc-081f4672cbf8 400
ManageResources List 08386d3d-7cc0-486b-a730-3b4cfe1b5509 401
Resources List 58160a6b-4396-4d6e-867c-65381fb5fbc9 402
Whereabouts List 9c2ef9dc-f733-432e-be1c-2e79957ea27b 403
CallTrackingPhoneMemo 239650e3-ee0b-44a0-a22a-48292402b8d8 404
Circulation a568770a-50ba-4052-ab48-37d8029b3f47 405
Timecard d5191a77-fa2d-4801-9baf-9f4205c9e9d2 420
Holidays 9ad4c2d4-443b-4a94-8534-49a23f20ba3c 421
KPIStatus List 065C78BE-5231-477e-A972-14177CC5B3C7 432
Report Library 2510D73F-7109-4ccc-8A1C-314894DEEB3A 433
PerformancePointContent List 481333E1-A246-4d89-AFAB-D18C6FE344CE 450
PerformancePointDataSource Library 5D220570-DF17-405e-B42D-994237D60EBF 460
PerformancePointDataConnections Library 26676156-91A0-49F7-87AA-37B1D5F0C4D0 470
PerformancePointDashboards Library F979E4DC-1852-4F26-AB92-D1B2A190AFC9 480
MicrosoftIMEDictionary List 1C6A572C-1B58-49ab-B5DB-75CAF50692E6 499
VisioProcessDiagram Library (Metric) 7E0AABEE-B92B-4368-8742-21AB16453D01 505
VisioProcessDiagram Library (US Units) 7E0AABEE-B92B-4368-8742-21AB16453D02 506
External List 00BFEA71-9549-43f8-B978-E47E54A10600 600
Pages Library 22A9EF51-737B-4ff2-9346-694633FE4416 850
Asset Library 4BCCCD62-DCAF-46dc-A7D4-E38277EF33F4 851
IssueTracking List 00BFEA71-5932-4F9C-AD71-1557E5751100 1100
AdministratorTasks List   1200
Health Rules   1220
Health Reports   1221
TranslationManagement Library 29D85C25-170C-4df9-A641-12DB0B9D4130 1300
LanguagesAndTranslators List 29D85C25-170C-4df9-A641-12DB0B9D4130 1301
Record Library DA2E115B-07E4-49d9-BB2C-35E93BB9FCA9 1302
PersonalDocument Library   2002
PrivateDocument Library   2003
Slide Library 0BE49FE9-9BC9-409d-ABF9-702753BD878D 2100