Quick Tip: Adding content database with stsadm

It is important when the content database need to upgrade the gui interface can not able to complete this operation.you have to use stsadm for doing that.

Command:
stsadm -o addcontentdb -url “<siteURL>” -databasename “<databaseName>” -databaseserver “<SQLServerName>”

Example
stsadm -o addcontentdb -url “http://blog.bugrapostaci.com” -databasename WSS_Content_Blog -databaseserver “postpoint2003”

You can get detail information from MSDN:
http://technet.microsoft.com/en-us/library/cc263422(office.12).aspx

 

 

Advertisements

Quick tip for relative paths using Style Library

Here is very good definition from msdn about usage of Style Library :

“In Office SharePoint Server 2007, the publishing features create a special document library, named the Style Library, which Microsoft uses to deploy standard CSS files and image files that are used in publishing sites. The Style Library is also commonly used as a deployment target by web designers and developers who are using CSS files and image files to apply branding elements to Office SharePoint Server 2007 publishing sites.

When you are developing a generic and reusable branding solution for SharePoint Server 2007 farms, you cannot use the Style Library because it exists only in publishing sites. Windows SharePoint Services 3.0 does not create the Style Library when you create other types of sites, such as a Team site, Blank site, or a Document Workspace. Fortunately, this is no longer a problem in SharePoint 2010.

In SharePoint 2010, every site collection has its own Style Library. That’s because Microsoft has moved the standard provisioning instructions for creating the Style Library out of the publishing features and into the Global site definition. Each time SharePoint Foundation 2010 creates a new site collection, it adds the Style Library to the top-level site. This makes the Style Library an ideal candidate for deploying CSS files and image files in a generic branding solution.”

Every web developer has faced with absolute or relative path problems for assets files.Working with relative paths makes you mad or Sometimes solution is using fullpath which is mostly problematic, ,sometimes needed extra codding etc. But what about Style Library:

For a bad example:
I assume that you have a masterpage file and bellowed line:

<asp:Image
ImageUrl="~/Style Library/CustomImages/BlogofBugra.jpg %>"
runat="server"
/>

For this scenario the image file can be shown from default.aspx or any root page no problem is here.
But if you open a system page for example _Layouts/settings.aspx . upss your images link are broken ….

To fix this issue using $SPUrl can help us
For a good examples:

<asp:Image
ImageUrl="<% $SPUrl:~sitecollection/Style Library/CustomImages/BlogofBugra.jpg %>"
runat="server"
/>

<SharePoint:CssRegistration
  name="<% $SPUrl:~sitecollection/Style Library/styles.css %>"
  After="corev4.css"
  runat="server"
/>

Quick Performance tip for CQWP

A quick tip for getting your Content Query Web Part results more quickly.Using ID attribute instead of using name attribute for FieldRef element.

A Good sample code for Performace

<Where> 
<Eq> 
<FieldRef ID="{ead7c4fb-4ae3-3496-b4bc-b77af4396a71}"></FieldRef> 
<Value Type="Text"> for good performace 
</Value>
</Eq> 
</Where>

  A bad sample code for Performace

<Query>
   <Where>
      <BeginsWith>
         <FieldRef Name="Title" />
             <Value Type="Text">it takes more time </Value>
     </BeginsWith> 
 </Where>
</Query>

How to enable Query Latency Trend report for Sharepoint 2010

Sharepoint Server 2010 has contains builting Search administration reports. You can find them via
Central Administration -> Administrative Report Library -> Search Administration reports.

One of the reports that is very useful is the Query Latency Trend chart. This does not work out of the box because verbose query monitoring is disabled.

To enable the Query Latency Trend report, you must run the following Windows PowerShell cmdlets:

$app = Get-SPEnterpriseSearchServiceApplication “<application name>”
$app = Set-SPEnterpriseSearchServiceApplication -VerboseQueryMonitoring “True”
$app = Get-SPEnterpriseSearchServiceApplication “<application name>”
$app.Update()

Example:

$sar = Get-SPEnterpriseSearchServiceApplication
$sar.VerboseQueryMonitoring = $true
$sar.Update()
Resource:
http://technet.microsoft.com/en-us/library/ee808861.aspx

how to delete sharepoint timer job using powershell

When developing custom sharepoint timer jobs sometimes you want to delete junk jobs created by deployment attempts .

Warning !!! DO NOT DELETE ANY TIMER JOB UNLESS BE SURE

Searching listing and find timer job to delete.We need an id.
Get-SPTimerJob | where { $_.name -like “*<your search criteria>*” } |ft id,name

Set job to a variable
$job = Get-SPTimerJob -id <GUID>

And delete it.
$job.Delete()

just it.

Missing Sharepoint Central Administration application

Somehow our friendly Central Administration web application was deleted or collapsed irreversably. Than how could you reprovision it ? sure you can rerun Configuration Wizard but it will take time and makes lots of change. Thanks to Microsoft that we have console executable named psconfig.exe in DRIVE:\Program Files\Common Files\Microsoft Shared\Web Server Extentions\14\BIN\psconfig.exe

To provision CA use that command:

psconfig.exe -cmd adminvs -port 9999 -provision -windowsauthprovider onlyusentlm

Manages the SharePoint Central Administration Web application on the local computer. Takes the following optional parameters:

[-provision]

Provisions the SharePoint Central Administration Web application on this server. Provisioning creates a new SharePoint Central Administration Web application and an application pool running under the server farm administrator’s account.

[-unprovision]

Unprovisions the SharePoint Central Administration Web application from this server. Unprovisioning removes the SharePoint Central Administration Web application and its application pool.

[-port <port number>]

The SharePoint Central Administration Web application port is a global setting to the server farm. When changing the port, a SharePoint Timer service job is dispatched to synchronize the port for all SharePoint Central Administration Web applications in the server farm. If a port is not specified, the port that is used for existing SharePoint Central Administration Web applications in the server farm is used. If a SharePoint Central Administration web Application has not been provisioned in the server farm, the default port selected will be random if a port is not specified.

[-windowsauthprovider <enablekerberos | onlyusentlm>]

The SharePoint Central Administration Web application authentication provider is a global setting to the server farm. When you change the authentication provider, a SharePoint Timer service job will be dispatched to synchronize the provider on all SharePoint Central Administration Web Applications in the server farm. If onlyusentlm is specified, NTLM will be the exclusive authentication provider for all SharePoint Central Administration Web applications. All other authentication providers are disabled and NTLM will be the only authentication provider allowed. If enablekerberos is specified, Kerberos authentication is enabled for all SharePoint Central Administration Web applications. If an authentication provider is not specified, the provider that is used for existing SharePoint Central Administration Web applications in the server farm will be used. If a SharePoint Central Administration Web application has not been provisioned in the server farm, the Kerberos authentication provider will be enabled if an authentication provider is not specified.

More Info:
Psconfig command-line reference (SharePoint Server 2010)
http://technet.microsoft.com/en-us/library/cc263093.aspx

How to prevent install Sharepoint using Group Policy

Many organizations would like to have the ability to control who can install SharePoint. For instance they might not want end-users to install SharePoint even if they are a local computer administrator. In SharePoint Foundation 2010 this ability to block SharePoint install will be possible via Active Directory group policy.
HKLM\Software\Policies\Microsoft\Shared Tools\Web Server Extensions\14.0\ SharePoint\

To block installation, set DWORD DisableInstall=00000001