Friday 23 May 2014

PowerShell script to copy files from one folder to another with in the same library

.ps1 code:

Add-PsSnapin Microsoft.SharePoint.PowerShell

$websiteurl = read-host "Enter site URL"
$web = Get-SPWeb $websiteurl


$LibraryName = read-host "Enter Library Name"
$docLibrary = $web.Lists[$LibraryName]
$SourceFolderURL = read-host "Enter the source folder URL"
$TargetFolderURL = read-host "Enter the target folder URL"
[string]$CurrDir=$args[0]
$logfile = $CurrDir + "\log.log"
$errorActionPreference = 'SilentlyContinue'

Function ProcessFolder([string]$sourcefolder,[string]$targetfolder)
 {
write-host "Source Folder $sourcefolder"
write-host "Target Folder $targetfolder"
write-host "Copying files started..............................."
$SFolder = $web.GetFolder($sourcefolder)
$TFolder = $web.GetFolder($targetfolder)
$Sfoldername =  $SFolder.name
$tfoldername =  $TFolder.name

foreach ($file in $SFolder.Files)
{
try
{
$file.CopyTo("$targetfolder/"+$file.Name,$true)
 [Microsoft.SharePoint.SPFile]$spFile = $web.GetFile("$targetfolder" + "/" + $file.Name)
}
# Display and log the filename which is failed to copy to destination folder
catch
{
$fname = $file.Name
 Write-Error 'An error occured while copying the file '$fname 'from Folder' $sourcefolder
 }

$sourceitem = $file.item
$targetitem = $spFile.item         
              
    if($spFile.Exists -eq $true)           
    {           
try
{        
$targetitem["Author"] = $sourceitem["Author"]
$targetitem["Editor"] = $sourceitem["Editor"]
$targetitem["Created"] = $sourceitem["Created"]
$targetitem["Modified"] =$sourceitem["Modified"]
$targetitem.Update() 
}
 # Display and log the filename which is failed to update metadata destination folder
catch
{
$fname = $file.Name
 Write-Error 'An error occured while updating the metada fields for the file' $fname 'from Folder' $sourcefolder 'as the user does not exists '
 }      
    }

}
foreach ($subfolder in $SFolder.SubFolders)
{
$subfoldername = $subfolder.name
$folderobj = $docLibrary.AddItem($TFolder.URL, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "$subfoldername")
$folderobj.Update();
$targetfolderurl = $folderobj.URL
#write-host $folderobj.URL

ProcessFolder "$websiteurl/$subfolder"  "$websiteurl/$targetfolderurl"

}

}

ProcessFolder "$SourceFolderURL" "$TargetFolderURL"
Remove-PsSnapin Microsoft.SharePoint.PowerShell

Powershell script to get the list of timer jobs that are executed between certain dates/times

.ps1 code:

cls
function Get-TimerJobs()
{
$SiteURL = read-host "Enter WebApplication URL"
$Site = Get-SPSite $SiteURL -ErrorAction SilentlyContinue 
$WebApp = $Site.WebApplication

$SDate  = read-host "Enter Start Date & Timefor ex:15/12/2011 11:00:00 AM"
$EDate = read-host "Enter End Date & Time for ex:15/12/2011 11:50:00 AM"
$startDate = [datetime]$SDate
$endDate = [datetime]$EDate


#GET ALL BETWEEN THAT TIME PERIOD
Write-Host "Fetching all jobs to JobHistoryOutput.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red
$WebApp.JobHistoryEntries | Where-Object {($_.StartTime -gt $startDate) -and ($_.StartTime -lt $endDate)} | select JobDefinitionTitle,WebApplicationName,ServerName,Status,StartTime,EndTime,@{Expression={($_.EndTime - $_.StartTime).TotalSeconds};Label="Duration (secs)"}
Write-Host "Done! Check JobHistoryOutput.csv for info." -ForeGroundColor Green

#GET ALL THAT FAILED BETWEEN THAT TIME PERIOD
Write-Host "Fetching all errors to JobHistoryOutputErrors.csv for $myStartTime - $myStopTime..." -ForeGroundColor Red
$WebApp.JobHistoryEntries | Where-Object {($_.StartTime -gt $startDate) -and ($_.StartTime -lt $endDate) -and ($_.Status -ne 'Succeeded')} | select JobDefinitionTitle,WebApplicationName,ServerName,Status,StartTime,EndTime,@{Expression={($_.EndTime - $_.StartTime).TotalSeconds};Label="Duration (secs)"}
Write-Host "Done! Check JobHistoryOutputErrors.csv for info." -ForeGroundColor Green
}
$results = Get-TimerJobs
$results | Out-GridView



Powershell script to get the list of all available webparts on each page with in the sites.

# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

function enumerateWebParts($Url) {
    $site = new-object Microsoft.SharePoint.SPSite $Url

    foreach($web in $site.AllWebs) {
      
        if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {
            $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
            $pages = $pWeb.PagesList

            Write-Host "Processing Web:" $pWeb.Url "..." -ForegroundColor Magenta

            foreach ($item in $pages.Items) {

                $fileUrl = $webUrl + "/" + $item.File.Url
                Write-Host "   " $fileUrl -ForegroundColor Green
        try
        {              
            $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
        }
        catch [Exception]
        {
            $fileUrl = $webUrl + "/" + $item.File.Url
            write-host "error occured processing the page     $fileUrl"      
            continue;
        }  
                $wps = $manager.webparts
                $wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label="Type"}

            }
        }
    else {
            Write-Host "   Not a publishing web:" $web.Url". Looking for Site Pages library." -ForegroundColor Magenta
            $pages = $null
            $pages = $web.Lists["Site Pages"]

            if ($pages) {
                Write-Host "   " $pages.Title "found." -ForegroundColor Green

                foreach ($item in $pages.Items) {
                        $fileUrl = $webUrl + "/" + $item.File.Url
            try
            {                   
                $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
            }
            catch [Exception]
            {
                $fileUrl = $webUrl + "/" + $item.File.Url
                write-host "error occured processing the page     $fileUrl"      
                continue;
            }
                    $wps = $manager.webparts
                    $wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"}, DisplayTitle, IsVisible, @{Expression={$_.GetType().ToString()};Label="Type"}
                }
            }
            else {
                Write-Host "    Site Pages library not found." -ForegroundColor Red
            }
        }
    $web.Dispose()
    }

 }
$webAppUrl = Read-Host "Enter the web application URL for ex:test.com"
#$csvpath = Read-Host "Enter the csv file path to create for ex: c:\test.csv"

$row = enumerateWebParts($webAppUrl)
$row | Out-Gridview

Powershell script to get all checked out documents

 The below script will not only list the checked out version but also lets us know if it is having checked in version or draft version

.ps1 code

# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

function enumerateWebParts($Url) {
        $site = new-object Microsoft.SharePoint.SPSite $Url

        foreach($web in $site.AllWebs) {
        foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
            foreach ($item in $list.CheckedOutFiles) {
                $string1 = $item.File.Url;
                try{
                if(!($string1.ToLower().Contains("_catalogs/".ToLower())) -and !($string1.ToLower().Contains("pages/".ToLower())))    {
                    $item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"No"};Label="Checked In Version"}
                }
                }
                catch [Exception]
                {
                }
            }
             foreach ($item in $list.Items) {
                        if ($item.File.CheckOutStatus -ne "None") {
                    $string1 = $item.File.Url;
                    try{
                    if(!($string1.ToLower().Contains("_catalogs/".ToLower()))  -and !($string1.ToLower().Contains("pages/".ToLower()))){
                        $item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Document URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"},@{Expression={"Yes"};Label="Checked In Version"}
                    }
                    }
                    catch [Exception]
                    {
                    }
                }
            }
        }

        $web.Dispose()
        }
 }
$webAppUrl = Read-Host "Enter the web application URL for ex:Myprogress-dev.progress.com"
$csvpath = Read-Host "Enter the csv file path to create for ex: c:\test.csv"

$row = enumerateWebParts($webAppUrl)
$row | Out-Gridview

       
   

Get all checked out pages from entire site collection

Usually when we migrate content from one server to other, all the pages and documents should be cheked-in, otherwise the pages might be locked by the system account for editing or some times the pages might get corrupted.

I have written this script, so that we can get all the checked out pages and make sure they are checked in before we take a content database backup.

.ps1 code

# Add SharePoint cmdlets reference
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

function enumerateWebParts($Url) {
    $site = new-object Microsoft.SharePoint.SPSite $Url

    foreach($web in $site.AllWebs) {
        $pages = $web.Lists["Pages"]
        #Write-Host "Processing Web:" $pWeb.Url "..." -ForegroundColor Magenta
    $pCheckedOut = $pages.CheckedOutFiles
    foreach($p in $pCheckedOut){
        $p | select-object @{Expression={$web.Url};Label="Web URL"},@{Expression={$_.Url};Label="Page URL"}, @{Expression={$_.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.CheckedOutBy.Email};Label="Checked Out Email"}, @{Expression={"No"};Label="Checked In Version"}

    }
foreach ($item in $pages.Items) {
                if ($item.File.CheckOutStatus -ne "None") {
$item| select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$_.File.Url};Label="Page URL"}, @{Expression={$_.File.CheckedOutBy};Label="Checked Out By"}, @{Expression={$_.File.CheckedOutBy.Email};Label="Checked Out Email"}, @{Expression={"Yes"};Label="Checked In Version"}
}
}
   
    $web.Dispose()
    }
 }
$webAppUrl = Read-Host "Enter the web application URL for ex:test.com"
$csvpath = Read-Host "Enter the csv file path to create for ex: c:\test.csv"

$row = enumerateWebParts($webAppUrl)
$row | Export-Csv $csvpath

Add new mime types to support different file extension types..

Sharepoint by default supports limited number of mime types. To extend its functionality to support other file types, we have created the below powershell script to add new mime types.

code for .ps1

Add-PsSnapin Microsoft.SharePoint.PowerShell
$URL= Read-Host "https://test.com"
$webApp = Get-SPWebApplication($URL)
$webApp.AllowedInlineDownloadedMimeTypes.Add("video/mp4")
$webApp.Update()
$webApp.AllowedInlineDownloadedMimeTypes
Remove-PsSnapin Microsoft.SharePoint.PowerShell

How can we set the New icon image for specific number of days beside documents in a document library?

We got a requirement where we need to display the new icon beside the documents for a specific duration of days.

The below powershell script will override the default duration

Add-PsSnapin Microsoft.SharePoint.PowerShell
$webappURL = Read-Host"Enter the webapplication url to set the duration for ex(https://test.com)"
$newIconDuration = Read-Host"Enter the duration"
if(($newIconDuration -ne null) -and ($webappURL -ne null))
{
$durationset = $webApp.DaysToShowNewIndicator
write-Host"current duration of new icon is"$durationset
$webApp = Get-SPWebApplication $webappURL
$webApp.DaysToShowNewIndicator = $newIconDuration
$webApp.Update()
write-Host"Successfully updated the duration of new icon"
}
else
{
write-Host"Please run the script with valid values"
}
Remove-PsSnapin Microsoft.SharePoint.PowerShell

Powershell script to get the Users profile properties..



  • Copy “GetUserProperties.bat” and “GetUserProperties.ps1” files to some location on any WFE servers of production.

  • Double click the batch file which generates a csv file (c:\ GetUserProperties.csv) with the list of user profile

  • Save this file as xlsx, so that we can view it properly.

Code for  GetUserProperties.ps1

 [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

# Enter your SharePoint site URL here...

$site = new-object Microsoft.SharePoint.SPSite("https://mysite.progress.com");

$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);
 

$ProfileManager = new-object 

Microsoft.Office.Server.UserProfiles.UserProfileManager($ServiceContext)

$AllProfiles = $ProfileManager.GetEnumerator()

write-host "UserName ,AccountName , Manager ,PictureURL"

foreach($profile in $AllProfiles)
{
$DisplayName = $profile.DisplayName

$AccountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].Value
$Picturevalue = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PictureURL].Value
$Manager = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::Manager].Value
if($Picturevalue  -ne "" )
{
write-host $DisplayName","$AccountName","$Manager","$Picturevalue
}
else
{
write-host $DisplayName","$AccountName","$Manager","$Picturevalue
}

}
$site.Dispose()



Code for GetUserProperties.bat:

 cd /d %~dp0

powershell -noexit -file    ".\GetUserProperties.ps1" "%CD%" >> "c:\GetUserProperties.csv"

pause

Powershell script to get all the site owners..




  • Copy “.bat” and “.ps1” files to some location on any WFE servers .
  • Double click the batch file which generates a csv file (c:\SiteOwnersList.csv) with the list of owners and Sites.
  • Save this file as xlsx, so that we can view it properly.


Note: You can change the csv file generation path by editing the “.bat”
 


The below script will get all the Site Owners if the site is having a group with name "SiteName+Owner"

Code for .ps1

Add-PsSnapin Microsoft.SharePoint.PowerShell

$spWeb = Get-SPweb "https://test.com"
$CommunityOwnersList = ""
write-Host "SiteName,Owners Of Site"
write-Host ","
foreach($subSite in $spWeb.Webs)
{
$Sitename = $subSite.Title

foreach($group in $subSite.Groups)
    {
        if(($group.Name -like "*Owners*") -and ($group.Name -like "*$Sitename*"))
        {
            $CommunityOwners = ""
            foreach($user in $group.Users)
            {
                $username = $user.Name

                $CommunityOwners = "$CommunityOwners  $username ; "
            }
           
        }

    }
    Write-host "$Sitename , $CommunityOwners"
$CommunityOwners = ""

    $subSite.Dispose()
}

$spWeb.Dispose()

Remove-PsSnapin Microsoft.SharePoint.PowerShell



Code for .bat (so that the above code can be executed with a single click)

 cd /d %~dp0

powershell -noexit -file    ".\test.ps1" "%CD%" >> "c:\test.csv"

pause


PowerShell script to get the List of all Sites, Lists, List Types,Number of items in each list..

param
(

[boolean] $WriteToFile = $true
)

#Get all lists in farm
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Counter variables
$webcount = 0
$listcount = 0
$totalCount = 0
$URL = Read-Host "Enter the website URL"
if($WriteToFile -eq $true)
{
$outputPath = Read-Host "Outputpath (e.g. C:\SiteMap.txt)"
}
if(!$URL)
{
#Grab all webs
$webs = (Get-SPSite -limit all | Get-SPWeb -Limit all -ErrorAction SilentlyContinue)
}
else
{
$webs = Get-SPWeb $URL
}
if($webs.count -ge 1 -OR $webs.count -eq $null)
{
if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "Total Sites = "$($web.count)}   
foreach($web in $webs)
    {
  
   #Grab all lists in the current web
    $lists = $web.Lists  
    Write-Host "Website"$web.url -ForegroundColor Green
    if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "Site URL  - "$($web.url)}
        foreach($list in $lists)
        {
            $listcount +=1 
            Write-Host " – "$list.Title         
            if($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "List Name – "$($list.Title)"    List Type - "$($list.BaseType) }
    foreach ($folderItem in $list.Folders)
    {
        
          $totalCount += $folderItem.Folder.ItemCount
    }
    f($WriteToFile -eq $true){Add-Content -Path $outputPath -Value "Total number of Items =  "$totalCount}
        }

    #$webcount +=1
    $web.Dispose()
    }

}
else
{
Write-Host "No webs retrieved, please check your permissions" -ForegroundColor Red -BackgroundColor Black
}

Update Title field with the File name for all files in a document library in sharepoint 2010

The below code will get all the files from all the sub folders to update the Title in a document library

            string strSiteCollURL = txtSiteCollURL.Text.ToString();
            string strDocLibr = txtDocLib.Text.ToString();
            try
            {
                SPSite site = new SPSite(strSiteCollURL);
                SPWeb web = site.OpenWeb();
                web.AllowUnsafeUpdates = true;

                SPFolder listobj = web.GetFolder(strDocLibr);
                SPDocumentLibrary libr = listobj.DocumentLibrary;
                SPQuery query = new SPQuery();
                query.ViewAttributes = "Scope=\"Recursive\"";
                SPListItemCollection listcoll = libr.GetItems(query);
                foreach (SPListItem item in listcoll)
                {
                    string eXtension = Path.GetExtension(item.Name);
                    string fileName = item.Name;

                    if (fileName != "")
                    {
                        if (eXtension != null && eXtension != "")
                        {
                            fileName = fileName.Replace(eXtension, "");
                        }
                        item["Title"] = fileName;
                    }
                    item.SystemUpdate();
                }

                System.Windows.Forms.MessageBox.Show("Successfully Updated the Titles");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

How to set the custom Access Denied page in Sharepoint 2010?

We need to follow the below steps to apply custom Access Denied page replacing the OOB application page.

Steps:

1) Create a new Application Page and name it based on your choice(for example AccessDenied.aspx)

2) Deploy this Application Page in to a different folder under Layouts, so that it wont conflict with OOB default.aspx page in the layouts folder

3) Once the page is deployed run the below powershell command/code /script to set the custom page as the login page

$WebAppURL= read-host "Enter the web application URL to which wish to set the Custom Access Denied Page"
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/Login/AccessDenied.aspx" -WebApplication $WebAppURL


How to set custom login page replacing the OOB login page in sharepoint 2010?

We need to follow the below steps to apply custom login page replacing the OOB application page.

Steps:

1) Create a new Application Page and name it based on your choice(for example default.aspx)

2) Deploy this Application Page in to a different folder under Layouts, so that it wont conflict with OOB default.aspx page in the layouts folder

3) Once the page is deployed run the below powershell command/code /script to set the custom page as the login page

$WebAppURL= read-host "Enter the web application URL to which wish to set the Custom Login Page"
Set-SPCustomLayoutsPage -Identity "Login" -RelativePath "/_layouts/Login/Default.aspx" -WebApplication $WebAppURL


4) Modify the web.config file to change the login page URL as below.

   <authentication mode="Forms">
      <forms loginUrl="/_layouts/login/default.aspx" />
    </authentication>


The above steps would automatically set the new custom login page.

Thursday 22 May 2014

Powershell script to copy content from one site to other site.

$ErrorActionPreference = "Stop"

Add-PSSnapin Microsoft.SharePoint.PowerShell
$SourcesiteCollectionUrl = read-host "Enter the source SiteCollection URL"
$TargetSiteCollectionUrl = read-host "Enter the target SiteCollection URL"
$dataFileName = read-host "Enter the data file name to create in C Drive"
$path = "C:\"+$dataFileName+".dat"
Export-SPWeb -identity $SourcesiteCollectionUrl -path $path

Import-SPWeb -identity $TargetSiteCollectionUrl -path $path

Powershell script to get all the site templates used with in a site collection

$siteURL =  read-host "Enter the url of the site collection to identift the temaplates used by them"
$site = Get-SPSite "http://testdev..com"
#$site = Get-SPSite $siteURL
  foreach ($web in $site.AllWebs) {
      $web | Select-Object -Property Title,Url,WebTemplate,WebTemplateID,Name
  }
 $site.Dispose()

Powershell script to create a webapplication

$ErrorActionPreference = "Stop"

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA 0
$webAppUrl = read-host "Enter WebApplication URL"
$appPoolUserName = read-host " Enter application pool user name"
$contentDatabaseName = read-host "Enter Content database name based on env specific(ex:UrlDev)"

function Main()
{

    If ($webAppUrl -eq $null)
    {
        $webAppUrl = "https://www.testLink.com"
    }

    Write-Host "Creating Web application ($webAppUrl)..."

    $hostHeader = $webAppUrl.Substring("https://".Length)

    $webAppName = "SharePoint - " + $hostHeader + "80"

    $membershipProviderName = "membership"
    $roleProviderName = "roleManager"
    $contentDatabaseName = "WSS_Content_"+$contentDatabaseName
    $appPoolName = $webAppName

    Write-Debug "hostHeader: $hostHeader"
    Write-Debug "webAppName: $webAppName"
    Write-Debug "appPoolName: $appPoolName"
    Write-Debug "appPoolUserName: $appPoolUserName"
    Write-Debug "contentDatabaseName: $contentDatabaseName"

    Write-Debug "Get service account for application pool ($appPoolUserName)..."
    $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName `
        -Debug:$false -EA 0

    If ($appPoolAccount -eq $null)
    {
        Write-Host "Registering managed account ($appPoolUserName)..."

        Write-Debug "Get credential ($appPoolUserName)..."
        $appPoolCredential = Get-Credential $appPoolUserName

        $appPoolAccount = New-SPManagedAccount -Credential $appPoolCredential `
            -Debug:$false
    }

    $windowsAuthProvider = New-SPAuthenticationProvider -Debug:$false
    $formsAuthProvider = New-SPAuthenticationProvider `
        -ASPNETMembershipProvider $membershipProviderName `
        -ASPNETRoleProviderName $roleProviderName `
        -Debug:$false

    $authProviders = $windowsAuthProvider, $formsAuthProvider

    $webApp = New-SPWebApplication -Name $webAppName -AllowAnonymousAccess -SecureSocketsLayer `
        -ApplicationPool $appPoolName -AuthenticationMethod "NTLM" `
        -ApplicationPoolAccount $appPoolAccount -Url $webAppUrl -Port 443 `
        -AuthenticationProvider $authProviders -HostHeader $hostHeader `
        -DatabaseName $contentDatabaseName `
        -Debug:$false

    Write-Host -Fore Green "Successfully created Web application ($webAppUrl)."
Remove-PSSnapin Microsoft.SharePoint.PowerShell
}

Main

Split Tool

Split tool is an excellent tool to get the detailed error information from uls log files based on the "Correlation ID " .

We need to input the time in "-minutes", so that it will check all the log files created before the given minutes of time.

I found it very useful and thought to post to help others who are still digging all the uls log files to find the error information.

you can download the tool from the below location in codeplex:

"http://split.codeplex.com/releases/view/55971"

Developer Dashboard in SharePoint 2010



The developer dashboard is a new feature in SharePoint 2010 this will help developers by giving additional performance and tracing information that can be used to debug and troubleshoot issues with page rendering time. It will give somewhat similar functionality of fiddler tool. The dashboard is turned off by default, but can be enabled via the object model or stsadm. Once enabled it will allow the following. 
  1. Tracking infinite loops inside code within web parts 
  2. Find out if pages are loading slowly.
This has three states ON, OFF and On demand. The following are the commands for each state

ON

STSADM -o setproperty -pn developer-dashboard -pv on 

OFF

STSADM -o setproperty -pn developer-dashboard -pv off 

ON DEMAND

This is very nice feature if you enable this mode you can make the dashboard enabled from SharePoint site itself whenever you need that

STSADM -o setproperty -pn developer-dashboard -pv ondemand
Note:  We can also log the performance of the custom code by wrapping the block of code in the using clause as below.



protected override void CreateChildControls()
{
    using (new SPMonitoredScope("My code block (WebPart1)"))
    {
        Thread.Sleep(50);
    }
}

 The above code will log the message in the Developer Dashboard.