How to change the farm passphrase
So you need to add back in that wfe or put a new server into the mix? You’re going to need the passphrase that was originially used when setting up the farm. But you’ve forgotten it so no you’re reading this and wondering why I don’t just get on with it. Alright then. Open up Powershell and enter:
$pphrase = ConvertTo-SecureString -asPlainText -Force
follow the prompts. Then enter
Set-SPPassPhrase -PassPhrase $pphrase -Confirm
follow the prompts and when asked to reenter the password reenter it, don’t try to use the variable.
Problem solved!
UDF for Military Julian
Here’s a function that will return the military julian equivalent of any date passed to it. The default is to return the current day’s.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
– =============================================
– Description: Function to return Military Julian in the format of YYDDD
– RETURNS: varchar data type
– INPUTS: date or default
– Example Using Today’s Date: select dbo.fnGetMilitaryJulian(default)
– Example Date: select dbo.fnGetMilitaryJulian(’01/08/2008′)
– Example Leap Year: select dbo.fnGetMilitaryJulian(’12/31/2012′)
– =============================================
ALTER FUNCTION [dbo].[fnGetMilitaryJulian]
(
– Add the parameters for the function here
@theDate datetime = null
)
RETURNS varchar(5)
AS
BEGIN
– Declare the ordinal part of the variable
DECLARE @miljul varchar(3)
–treat an empty string or spaces as a null
if rtrim(ltrim(@theDate)) = ”
set @theDate = NULL
DECLARE @d varchar(2);
DECLARE @m varchar(2);
DECLARE @y int;
DECLARE @firstofyear datetime;
DECLARE @yearpart varchar(2);
DECLARE @tempjul varchar(5);
set @m = 01;
set @d = 01;
– set year part on the date passed in
if @theDate is not null
BEGIN
set @y = year(@theDate);
set @yearpart = RIGHT(convert(varchar(4),year(@theDate)),2);
END
else
BEGIN
– set year part for today
set @y = year(getdate());
set @yearpart = RIGHT(convert(varchar(4),year(getdate())),2);
END
– finally determine the first day of the year requested
select @firstofyear = convert(datetime,@m +’-'+ @d +’-'+ convert(varchar,@y))
– get the ordinal day from the constructed date
if @theDate is not null
BEGIN
SELECT @miljul = convert(varchar(3),datediff(day,@firstofyear, @theDate) + 1)
END
else
BEGIN
– set miljul for today
SELECT @miljul = convert(varchar(3),datediff(day,@firstofyear, getdate()) + 1)
END
– insure the ordinal day is 3 digits long
set @miljul = right(replicate(’0′,3) + @miljul,3)
RETURN @yearpart + @miljul
END
Sharepoint 2010 TemplateIDs
When troubleshooting or creating sites in powershell here’s a handy list of templateIDs, Template Titles and Template Names.
| Template ID | Title | Name |
|---|---|---|
| 0 | Global template | GLOBAL#0 |
| 1 | Team Site | STS#0 |
| 1 | Blank Site | STS#1 |
| 1 | Document Workspace | STS#2 |
| 2 | Basic Meeting Workspace | MPS#0 |
| 2 | Blank Meeting Workspace | MPS#1 |
| 2 | Decision Meeting Workspace | MPS#2 |
| 2 | Social Meeting Workspace | MPS#3 |
| 2 | Multipage Meeting Workspace | MPS#4 |
| 3 | Central Admin Site | CENTRALADMIN#0 |
| 4 | Wiki Site | WIKI#0 |
| 9 | Blog | BLOG#0 |
| 7 | Document Center | BDR#0 |
| 14483 | Records Center | OFFILE#0 |
| 22 | Personalization Site | SPSMSITE#0 |
| 39 | Publishing Site | CMSPUBLISHING#0 |
| 53 | Publishing Site | BLANKINTERNET#0 |
| 53 | Publishing Site with Workflow | BLANKINTERNET#2 |
| 33 | News Site | SPSNHOME#0 |
| 34 | Site Directory | SPSSITES#0 |
| 38 | Report Center | SPSREPORTCENTER#0 |
| 47 | Collaboration Portal | SPSPORTAL#0 |
| 50 | Search Center with Tabs | SRCHCEN#0 |
| 51 | Profiles | PROFILES#0 |
| 52 | Publishing Portal | BLANKINTERNETCONTAINER#0 |
| 54 | My Site Host | SPSMSITEHOST#0 |
| 90 | Search Center | SRCHCENTERLITE#0 |
| 90 | Search Center Advance | SRCHCENTERLITE#1 |
| FAST Search Center | SRCHCENTERFAST#0 | |
| Visio Process Repository | visprus#0 |
Sharepoint 2010 Elements by Scope
When deploying features to SharePoint 2010 it’s good to know what element types are available in each scope. Here is just such a breakdown.
Scope |
Element |
| Web | Content Type
Content Type Binding Control Custom Action Custom Action Group Custom View Event Field Hide Custom Action List Instance List Template Module Property Bag Workflow Actions Web Template |
| Site | Content Type
Content Type Binding Control Custom Action Custom Action Group Event Field Hide Custom Action List Instance List Template Module Property Bag Template Association Workflow Workflow Actions Workflow Association |
| Web Application | Control
Custom Action Custom Action Group Document Converter Hide Custom Action Template Association Web Template Workflow Association |
| Farm | Control
Custom Action Custom Action Group Hide Custom Action Template Association Workflow Association |
The Immutable Content Source
OK… I know there were probably good intentions behind placing a default content source into the Enterprise Search Application. Maybe the intent was to provide an example on how to set one up. Maybe the installation of the search service would crash at some point without having at least one content source defined and in place. But why for the love of gawd would it be made Read-only and undeletable?
I’ve tried changing it’s name to something meaningful and putting my own start addresses in but the name can’t change. I’m not fond of ‘Local SharePoint sites’ since all my searches are on a local site. The name kind of loses it’s usefulness.
I tried using the Powershell cmdlet Remove-SPEnterpriseSearchCrawlContentSource but it too had some bad news for me: Modifying a read-only content source is not allowed.
Unable to do anything else I added my own url and moved on to other tasks: http://donotusethisbloodyreadonlyundeletableaccount
The site template requires that Feature {GUID} be activated in the site collection.
Today I had to move a site from it’s current site collection to a new one. I used the save site as template to put it all into a wsp. upon uploading the site I got the error The site template requires that Feature {7c637b23-06c4-472d-9a9a-7c175762c5c4} be activated in the site collection. I used the following to activate the feature (ViewFormPagesLockDown) stsadm:
stsadm -o activatefeature -url “myurl” -filename ViewFormPagesLockDown\feature.xml
We retried the upload and got hit with another missing feature error. This time it was for OSSSearchSearchCenterUrlSiteFeature. Running this therough the same stsadm command we were finally able to get our wsp loaded into the new site collection.
Before running into these errors we compared the site collection features on the destination site collection and on the originating collection by walking down the list in the interface (“Features” in Site Settings). Had we not done that first I would have been activating more than these two!
For a handy lookup see Stan Kirkber’s blog post here.
Handy sp_helpdb
I came across a really handy system stored procedure tonight that is available in SQL Server 2008 R2 (and earlier) called ‘sp_helpdb’. Issuing the command ‘exec sp_helpdb ‘<dbname>’ returns a plethora of info that I used to get by running any number of different queries.
In one finger friendly statement you can get the DB Name, it’s size and ID, the owner, when it was created, the status, compatability setting and details on its files.
Click the image to see it in all it’s glory!
Give it a whirl. If it doesn’t work for you check that your login is a member of the public role. If it still doesn’t work and you are getting this error:
Msg 15009, Level 16, State 1, Procedure sp_help, Line 66
The object ‘<dbname>’ does not exist in database ‘<dbname>’ or is invalid for this operation.
then check your permissions or set the db with ‘Use <dbname>’ before executing.
Fixing Event 6398
Our Web Analytics account went wonky on us about 2 weeks ago. The reports suddenly started showing 0. I dug into the Event Viewer and found an error coming from SPUsageImportJobDefinition. Filtering on the EventID (6398) I discovered that there were quite a few for both Search and UsageImport activities.
The Web Analytics Trigger Workflows Timer Job was scheduled to run daily at 5AM so I grabbed the ULS log from that time and discovered that there is an error importing the web analytics usage logs. The error was a an update conflict. Hmmm… This sounded alot like a problem I had on our 2007 farm so i looked through my notes and found this solution.
This solution, out of the many out here, lined up with the way this issue manifested in our various logs . As alwys, It is best to do alot of googling before settling on any method.
Do this on The App Server and on all WFEs
Stop the SharePoint 2010 Timer Service and the SharePoint Administration Service.
Navigate to C:\ProgramData\Microsoft\SharePoint\Config. You may not see the ProgramData directory as it’s a hidden file.�
If they’re hidden, click on ‘Computer’ (on the server of course) to open Windows Explorer. Type Alt-T to get to the ‘Tools’. Select ‘Folder Options’, Click the ‘View’ tab. Select ‘Show hidden files and folders’ under ‘Hidden files and folders’. Hit ‘OK’ and get back to work.
Back in C:\ProgramData\Microsoft\SharePoint\Config you will see 2 directories. One contains files of type ‘PersistedFile’. The other has xml files. This is the directory to work in.
Find the cache.ini file and copy it 1 level up (for safety sake). Delete all the xml files (not the cache.ini file)
Open the cache.ini file and overwrite the number with a ’1′. Just type the number and save it.
Delete the cache.ini file you saved in the config directory for clarity’s sake. We like clarity.
Do the same on all servers.
Now start the Timer Service and the SharePoint Administration Service back up and the issue should be fixed. You should see the xml files repopulate into the directories you just cleaned.
For an authoritative run through on the process, albeit for a MOSS installation, please see KB 939308. The procedure is identical on 2010
Resume a Failed upgrade
If you attempt to install a CU or a Service pack on a content database that has missing features or orphaned items the upgrade will fail on that db. It will succeed for any db that is in good shape and for the system databases. After fixing the errors that caused the failure you will need to run the Powershell command Upgrade-SPContentDatabase. There are a couple of ways (maybe a few hundred in reality but here’s two) to accomplish this task.
1. Find the GUID of the contentDB from Central Admin’s “Manage Content Databases”page. I right click the link and ‘Copy Shortcut’. This will get me the urlencoded GUID of the contentdb I’m after. I paste that into notepad, copy the encoded guid portion and then visit an online urldecoder. I like to use Eric Meyers. Remove the squigglies around it and you’re good to go. Then I run the following on my Application Server:
Upgrade-SPContentDatabase -Identity F82A6E93-7C83-4115-B5FA-8CDD94541ED4
Another way is to do it all using powershell:
$contentdb = Get-SPContentDatabase | where-Object{$_.Name -match “DBServer\DBName”}
Upgrade-SPContentDatabase -Identity $contentdb
Either way if the db fails again it will be readily noticeable. You’ll get a nice error message in easy to read red. Included is a path to the error log for you to pick through with details on what caused the failure.
Keep in mind that this command should be run in the off hours!
70-667 Passed!
I passed the MCTS exam 70-667 this past Friday! I relied on James Pyles Study Guide and Technet Articles. Being able to work through the labs on my own home developer machine helped alot too. I bought a Dell XPS8300 with 6 Gb of Ram and later expanded it to 16Gb of RAM for $99.99! I added an Intel 120Gb SSD and vmware to end up with a farily responsive dev box. It sure beats trying to use the Labs provided by technet! Take advantage of the plethora of free training materials available thru Microsoft.
