Translate

Saturday, August 31, 2013

Searching through ULS logs for a correllation ID (Merge-SPlogFile)

As tempting as it is to start opening ULS logs that surround the time of your correlation ID, you should avoid that practice, unless you have lots of time on your hands.

Here is an easier and more effective way to get at your issue:


Use the Merge-SPLogFile

Merge-SPLogFile -Path <String> [-Area <String[]>] [-AssignmentCollection <SPAssignmentCollection>] [-Category <String[]>] [-ContextFilter <String[]>] [-Correlation <Guid[]>] [-EndTime <DateTime>] [-EventID <String[]>] [-ExcludeNestedCorrelation <SwitchParameter>] [-Level <String>] [-Message <String[]>] [-Overwrite <SwitchParameter>] [-Process <String[]>] [-StartTime <DateTime>] [-ThreadID <UInt32[]>]

You must specify the Path parameter so that a file can be created that holds just the lines that correspond to your search criteria.

You can search of a string of text using the -message parameter and it accepts wildcards (*)

It looks through all your log files and returns just the lines containing your search criteria.

http://technet.microsoft.com/en-us/library/ff607721(v=office.14).aspx


This example looks through all servers in your farm and merges the logs for correlation id 'B4BBAC41-27C7-4B3A-AE33-4192B6C1E2C5 that occurred between 4 and 415 pm

Merge-SPLogFile –Path "C:\Logs\FarmMergedLog.log" -Correlation B4BBAC41-27C7-4B3A-AE33-4192B6C1E2C5 –StartTime "05/01/1967 16:00" – EndTime "05/01/1967 16:15"

Check out this blog for yet another way to peel this egg, get-splogevent:

http://zimmergren.net/technical/sp-2010-find-error-messages-with-a-correlation-id-token-in-sharepoint-2010

Sunday, August 25, 2013

Help to avoid and partially clean up missing server side dependencies

Orphaned items within sites can cause all sorts of issues:  Missing Server side dependencies, Sites not replicating correctly amongst farm servers, trouble with cumulative updates, odd web part behavior, and who knows what else.

It's been my experience that server side dependencies result from numerous things, such as poorly written code that is not tested correctly in a development environment.  Code that deploys fine, but does not retract cleanly after successful deactivation of it's features. Or features that are not deactivated before the solutions, that deployed said feature(s), are retracted and\or removed.

One way to avoid dependencies and orphaned SharePoint features

Before retracting a solution, make sure to deactivate the SharePoint feature or features that the solution provided.  You can do this by knowing which of the thousands of sites you support have the feature activated, or you could run a script written by Gary Lapointe, founding partner of Aptillon that deactivates or activates the feature:

http://blog.falchionconsulting.com/index.php/2008/11/activating-features-at-different-scopes-using-stsadm/

One way to clean out some, not all, of your server side dependencies

Orphaned sites, lists, libraries, documents, and references often result when features are unable to be deleted due to solutions that they were dependent on are no longer present in the farm.  This occurs when solutions are retracted and removed without features first being deactivated, followed by deletion of the site, list, library, document, or item that referenced a feature that was referencing a solution that was erroneously retracted.    In cases of site deletion, this is true despite SharePoint reporting back that "Your web was deleted".  In actuality, it may or may not be completely deleted.

No PowerShell for this, yet

Use the DatabaseRepair switch of the somewhat deprecated stsadm command to dig in and even remove some server side dependencies.    "Isnt the stsadm deprecated to  the Management Shell\PSSnapin for SharePoint"  and the answer is yes, in most cases it is.  But in this case and unlike many other stsadm switches, -databaserepair has not been replaced by powershell.

Here is the official list of all the stsadm switches, that powershell is about to replace, at the time of this post:

http://technet.microsoft.com/en-us/library/ff621084(v=office.14).aspx - stsadm to powershell chart

Reason for "Partially clean up" in the subject line

"The databaserepair operation can detect and repair database corruption for only the following types of orphaned items in a content database:
  • A Windows SharePoint Services Web site that does not have a parent Windows SharePoint Services Web site
  • A subweb that does not have a parent Windows SharePoint Services Web site
  • A list that does not have a parent Windows SharePoint Services Web site
  • A document that does not have a parent document library
  • A list item that does not have a parent list
  • A Web page that does not have a parent Windows SharePoint Services Web site
  • Missing security scopes on Webs, lists and items" - TechNet - http://technet.microsoft.com/en-us/library/cc263282(v=office.14).aspx
It's best to make a backup of your site, backup-spsite, before proceeding, and even better to perform this in a development or testing environment.

Here are the steps detect the issues that are causing the corruption:

  1. Backup the site using backup-spsite
  2. Know the name of the content database of the site, you could get this using the GUI or powershell.  If (Get-SPwebApplication <URL>).contentdatabases returns more than one content databases, one way to find the content db hold your site is to run (get-spcontentdatabase <Name of Database>).sites on each database.  Or you could probably find a script for that somewhere
  3. stsadm -o databaserepair -url http://anothersharepointblog.blogspot.com -database wss_content_8083

Here are the steps to remove the corruption\repair the issues:
  1. Steps from above
  2. stsadm -o databaserepair -url http://anothersharepointblog.blogspot.com -database wss_content_8083 -deletecorruption

Examples from Technet

Detect an orphan site

To detect orphaned items, use the following syntax:
stsadm -o databaserepair -url http://<URL_of_WindowsSharePointServices_Site> -databasename <name of database that contains the orphan item>

Delete an orphan site

To delete orphaned items, use the following syntax:
stsadm -o databaserepair -url http://<URL_of_WindowsSharePointServices_Site> -databasename <name of database that contains the orphan item that is to be deleted> -deletecorruption

Sunday, August 18, 2013

Connect a server to a farm using powershell - SharePoint 2013 or 2010

Log onto each additional server that you wish to join into the farm

    Open the  ”SharePoint 2010 Management Shell”  administratively (right-click and select “Run as administrator”). The shell will load with a message that the local farm is not accessible. This is expected as we have only installed the binaries.   

 Connect the server to the farm with the following command:


Connect-SPConfigurationDatabase -DatabaseName "SharePoint2010_Config" -DatabaseServer "SharePoint2010SQL" -Passphrase (ConvertTo-SecureString "1Qaz2Wsx" -AsPlaintext -Force)


    

Make sure to use the same database names and database server names.

    
1.  Install the help files.


    Install-SPHelpCollection -All

2. Secure the resources used by the server (files and registry).


    Initialize-SPResourceSecurity
 

3.  Install and provision the farm services.


    Install-SPService

4.  Install the features on the server.


    Install-SPFeature –AllExistingFeatures

 

5.   Install the application content.


    Install-SPApplicationContent
 

Development farm Optional: Disable the loopback check. If this is a development install, outright disabling the check should be fine. For production environments, the loopback check should be left in place and BackConnectionHostNames should be used in its place. See KB 896861


    New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword

Sunday, August 11, 2013

Create a SharePoint 2010 or SharePoint 2013 two server farm using Powershell

Check out the reference for this post:   http://blog.falchionconsulting.com/index.php/2009/10/sharepoint-2010-psconfig-and-powershell/

It contains what follows in script format; which is much easier to use.  This post just breaks it down.


Pre-requisites:

Install the SharePoint binaries on each server in your farm.

Harden IIS - Move IIS to E:

Continue with Setup.exe and select “Complete” as the installation type. This will create a farm as opposed to a single server installation.

After the install has completed, you will be asked if you would like to complete the “SharePoint Products Configuration Wizard”. Uncheck the box and do not run the wizard at this time.

Since this is the first server in your farm, you need to provision Central Administration:

1. Open the  ”SharePoint 2010 Management Shell”  as administrator (right-click and select “Run as administrator”). The shell will load with a message that the local farm is not accessible. This is expected since the farm has not been created and only the binaries are installed on the front end server.

2. Create the initial configuration/content database for the farm, replace values within quotes as you see fit:

New-SPConfigurationDatabase –DatabaseName “SharePoint2010_MyConfigDBName” –DatabaseServer “NetBIOSNameOFMySQLServer_Not_FQDN” –AdministrationContentDatabaseName “SharePoint2010_AdminDB” –Passphrase (ConvertTo-SecureString “1Qaz2Wsx” –AsPlaintext –Force) –FarmCredentials (Get-Credential)

Note:  The server names use NetBios names not FQDN's

3.  After the initial creation of the farm configuration database and farm admin database you need to close and re-open the “SharePoint 2010 Management Shell”. Notice, that the message about not contacting the farm is resolved.



4.  Secure the resources used by the server (files and registry).

Initialize-SPResourceSecurity

Enforces resource security on the local server.

5.  Install and provision the farm services.
Install-SPService

Installs and provisions services on a farm.


6.  Install the features on the server.
Install-SPFeature –AllExistingFeatures

Scans for existing, but unregistered features, and then registers them with the farm.  Installs a SharePoint Feature by using the Feature.xml file.


7.  Provision Central Administration.
New-SPCentralAdministration -Port 1234  -WindowsAuthProvider "NTLM"

Creates a new SharePoint Central Administration Web application.

8.  Install the help files.

Install-SPHelpCollection -All

This makes the normal help files available when a user clicks the white question mark inside of the blue circle or presses f1.

9.  Install the application content.
Install-SPApplicationContent

Copies shared application data to existing Web application folders.


10.  Optional: Disable the loopback check. If this is a development install, outright disabling the check should be fine. For production environments, the loopback check should be left in place and BackConnectionHostNames should be used in its place. See KB 896861.

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword

Sunday, August 4, 2013

Searching through a ULS log

Here are a few tips to use when searching through a ULS log for errors and/or correlation ID's is coming up null:

1. Open your ULS.Log in notepad or notepad ++ and search on the just the first 8 digits, if all 32 are resulting in nothing, so use f4385bd3, from the image below, versus the entire string.
2. Remove the hypens and search
3. Search on ERR and mark the box to use case sensitive
4. Open the ULS log with ULSviewer and repeat above




Saturday, August 3, 2013

Exporting and Importing - Cannot import site due to wrong template

When you're migrating sites using export-spweb and import-spweb, you might receive an error message on the import, when reviewing the import log, and in your shell, similar to this:


FatalError: Cannot import site. The exported site is based on the template SPS#0
 but the destination site is based on the template BLANKINTERNET#2. You can import sites only into sites that are based on same template as the exported site.
   at Microsoft.SharePoint.Deployment.WebSerializer.IsWebTemplateCompatible(String sourceWebTemplateName, String destinationWebTemplateName)
   at Microsoft.SharePoint.Deployment.WebSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
   at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,
Boolean isChildObject)
   at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type object
Type, Boolean isChildObject, DeploymentObject envelope)
   at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
   at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
   at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
   at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
   at Microsoft.SharePoint.Deployment.SPImport.Run()
Progress: Import Completed.
Finish Time: 1/22/2009 1:04:44 PM.
Completed with 1 warnings.
Completed with 1 errors.
Log file generated:
        D:\prodsitecollection.cmp.import.log

The workaround for this is to create the correct type of destination site.

To determine what type of site is based on the BLANKINTERNET#2 site template, perform the following:

1. Open a SharePoint Management Shell
2. Type Get-SPwebTemplate and press enter


One way to avoid this error all together is to create the destination (target site) based on the correct template from the get-go.  You can do this by determining the type of site you're working with
by looking at the web template property of the web.

1. Open a SharePoint Management Shell
2. Know your site URL
3. Type everything between the quotes, and not including the quotes "(get-spweb http://servername/sites/sharepointrocks).webtemplate"

It's not fool proof but is a good start. And, don't be fooled by the webTemplateID property, that is not the number that we're looking for.  See below, the /sites/yo is a team site, so if WebTemplateID were truly the answer to the # part of this question, it would show 0, not 1, because the name property for the Team Site template is, STS#0, not STS#1.  STS#1 is for the Blank Site.


Answer:  Trial and error target site creation until import works, or view the HTML source of the home page for the site and search for 'g_wsaSiteTemplateId' - the answer will be evident, you will see the template used to create the site.



Popular Posts