Friday, June 15, 2012

To determine the SharePoint Server 2010 version installed in your system

Method 1: Using Power Shell:
1. Open the Start > SharePoint 2010 Management Shell
2. Type the cmdlets as follows
(get-spfarm).buildversion
This gives the output as follows

Method 2 : Using Central Administration:

1. Open SharePoint 2010 Central Administration > Upgrade and Migration

2. Open Check product and patch installation status under the Upgrade and Patch Management

This gives the output as follows















Method 3:
1.       Open SharePoint 2010 Central Administration > System Settings
2.       Click the link Manage servers in this farm under Servers section

3.       You will see the configuration database version











OSQL Tool

OSQL is a command line tool that allows you to issue commands to Microsoft SQL Server. To run OSQL, simply bring up a DOS box and type OSQL followed by any required switches. You can view the complete OSQL command syntax with:
OSQL -?
This technical note describes only those switches required to perform the operations included in the note. Note: OSQL switches are case-sensitive. Switches:
·       -S <sql-server-name> - the name of the SQL Server, including instance, if applicable. You may use "." (without quotes) if you are running OSQL on the same machine as SQL Server.
·       -d <database-name> - the name of the database on which the operation is to be performed. For example -d ExpressDB.
·       -U <user-name> - the SQL Server user account under which to run the specified command.
·       -P <password> - the password associated with the specified user account.
·       -E - use NT authentication to interact with SQL Server
·       -Q "<SQL-command>" - the command to issue to SQL Server.
·       -i <file-of-SQL-commands> - a file containing one or more commands to issue to SQL Server.
OSQL can also operate interactively. If you specify only the server, database, user name, and password, you will be presented with a prompt allowing you to enter and execute commands one at a time. The command exit exists interactive mode.

The examples below using the following sample values for the switch parameters described above:
·       Database: ExpressDB
·       SQL Server: .\ESM - that is, the ESM instance of SQL Server on the current machine
·       User: sa - the SQL Server administrative account
·       Password: mysapwd - the password associated with the sa account
Important notes
1.    The operations described in this technical note require SQL Server administrative privileges. This means you must either use the SQL Server sa account, another administrative-capable account, or be logged into Windows under an account that has SQL Server administrative rights.
2.    SQL commands are issued in the context of the machine running SQL Server. If you use OSQL on one machine to issue commands to SQL Server on a different machine, any file/path information specified must be in the context of the SQL Server machine, not your local machine.
Steps to RESTORE database
Step 1: Start-> Run-> type “cmd”








Step 2: Type the below comments










-S  = <<Server>> - Server name
-E  = use NT authentication to interact with SQL Server
-Q = the command to issue to SQL Server (Normal SQL query which we used to run using SQL Management Studio Tool)












 

My Links webpart's text alignment issue in SharePoint 2010

This issue can be resolved in two different ways:

1: Just create the new CSS class in your custom style sheet
DIV .cbq-layout-main { TEXT-ALIGN: left;}
2. Open the PageLayout which is used for this webpart, change the PageLayout's <td  "style=TEXT-ALIGN: left;">

Get the list of pages with currently in checkout status with which user user using PowerShell

Below Power Shell script help to find the list of pages with currently in checkout status with which user:

function Get-AllCheckedOutPagesByWhichUser($WebAppName)
{
    $webapp = Get-SPWebApplication $WebAppName
   
    foreach ($site in $webapp.Sites)
    {
        foreach ($web in $site.AllWebs)
        {
            #$site.url + "|" + $web.Url + "|" + $web.Url
            foreach ($list in $web.lists)
            {
                if (($list.Title -eq "Pages") -and ($list.Items.Count -gt 0))
                #if ($list.Title -eq "Pages")
                {
                    #$list.Items.Count
                    $pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
                    try
                    {
                        foreach($pubPage in $pubWeb.GetPublishingPages())
                        {
                            if ($pubPage.ListItem.File.CheckOutStatus -eq “LongTerm”)
                            {
                                $web.Url + "/" + $pubPage.Url + " | " +  $pubPage.ListItem.File.CheckOutStatus + " | " + $pubPage.ListItem.File.CheckedOutBy.UserLogin
                            }
                           
                        }
                    }
                    catch [System.Exception]
                    {
                        write-host $_ -ForegroundColor RED
                    }
                }
            }
        }
    }
}
Get-AllCheckedOutPagesByWhichUser -WebAppName "http://Webapplicationname/"

File Not Found Error on SharePoint 2010

DB permission issue While Creating Web Application using PowerShell

Scripts that I have tested.
Write-Host ">>>>>>>>>>Process Started>>>>>>>>>>>>>>"
Write-Host ""
New-SPWebApplication -Name "Test" -Port 80 -HostHeader "Test-d" -Path "C:\inetpub\wwwroot\wss\VirtualDirectories\Test-d80" -AuthenticationMethod "NTLM"  -SecureSocketsLayer:$false -ApplicationPool "Test" -URL "http://Test-d/" -ApplicationPoolAccount (Get-SPManagedAccount "Server\Administrator") -DatabaseServer "ServerName" -DatabaseName "test-d"
Write-Host ""
Write-Host ">>>>>>>>>>Process Ended>>>>>>>>>>>>>>"
Note:
This is DB permission issue for the user account Server\Administrator. Kindly check it, the user which you had used here have DB access rights both read and write permission on ServerName DB Server.