Wednesday, 27 June 2012

How to find Site Collection size in SharePoint 2010

To get the Size (in MB) of all Site collections in your SharePoint 2010 Farm

You can use STSADM commands and Powershel script.

STSADM Cmd:

Please navigate to below path

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
and type as    STSADM.exe -o enumsites -url htt:// SharePoint Site

check for detailed information here


2. By using with PoweShell script
Open SharePoint 2010 Management Shell as administrator

---> $sc = Get-SPSite http://sharepointsite/
---> $sc.usage
this will give you the output like as below


If you want to know about the storage of Site Collection only then use the below script

Get-SPSite | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | Format-Table -AutoSize

the above script will give you the site collection size in megabytes.


If you want a copy of site collections size properties in html file, then please use below script

Get-SPSite | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html -title "Site Collections sort by size" | Set-Content SizeReport.html

to overcome the yellow color warning message please use the parameter as -Limit ALL

Get-SPSite -Limit ALL | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | ConvertTo-Html -title "Site Collections sort by size" | Set-Content SizeReport.html

For find out storage space allocation's and Increase Storage please check with below links FYI.,
http://blogs.msdn.com/b/sowmyancs/archive/2008/11/15/how-to-find-out-the-storage-space-allocation-details-a-site-through-code.aspx
http://social.technet.microsoft.com/forums/en-US/sharepointadmin/thread/d6cb11d9-6ed2-4344-aac9-4ca72d8b2c40
http://blogs.officezealot.com/mauro/archive/2005/03/25/4425.aspx
http://sharepointyankee.com/2011/12/28/how-much-storage-space-is-my-site-collection-using/

Friday, 22 June 2012

Rename SharePoint webapplication and SharePoint standalore server names

Rename SharePoint 2010 web application :

If anybody would like to rename a SharePoint 2010 web application name to correct the misspellings, you can simple PowerShell script.

The following script would rename the SharePoint application name only, not to IIS site and the Application pool,

First create PowerShell file(.ps1) with notepad by using with below code

$rwa=Get-SPWebApplication | where {$_.Name -match "Old Web Application Name"}
$rwa.Name
$rwa.Name="New Web Application Name"
$rwa.Update()
Get-SPWebApplication | where {$_.Name -match "New Web Application Name"}

Just save in under D:\renameapp.ps1 on your SharePoint 2010 server.
Open SharePoint 2010 Management Shell as Administrator mode, and do as like below screen shot


Go to Central Admin--> Manage web application--> here you should able to see the Web application with updated new name.

Rename SharePoint standalone server  :

Rename a stand-alone server by using with below Windows Powershell

Rename-SPServer [-Identity] <OriginalServerName> -Name <NewServerName>
To ensure that the rename operation is complete, run iisreset /noforce at a Windows command prompt
For detailed information and precess about Renaming the SharePoint standalone server name see this technet library.

Read More option for SharePoint Blog posts.

In my blog site while user reading the posts, users are not Familiar to read long posts and for checking all posts he needs to scrool page continiously.

SharePoint blog does not provide a feature to restrict lines or characters to display the content.

After much researching i found the solution from this blog

To display blog post content in limited size :
  1. Take a backup of blog.xsl file from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\XSL
  2. Edit the file and go to around line 15, here we will add the JQuery Source code.
  3. Naviage to http://jquery.com/ and copy the JQuery source code from "downlod JQuere"
  4. I have copied http://code.jquery.com/jquery-1.7.2.js source code and pased between CDATA Tags.
<!--<xsl:template match="View[@BaseViewID='0' and List/@TemplateType='301']" mode="full">
<script type="text/javascript">
<![CDATA[
   /*!
   * jQuery JavaScript Library v1.7.2
   * http://jquery.com/
   *
   * Copyright 2011, John Resig
   * Dual licensed under the MIT or GPL Version 2 licenses.
   * http://jquery.org/license
   *
   * Includes Sizzle.js
   * http://sizzlejs.com/
   * Copyright 2011, The Dojo Foundation
   * Released under the MIT, BSD, and GPL Licenses.
   *
   * Date: Wed Mar 21 12:46:34 2012 -0700
   */
   (function( window, undefined ) {
   ..............
   ..........//
   })( window ); ]]>
</script>
<xsl:apply-templates select="." mode="RenderView" />
<xsl:apply-templates mode="footer" select="." />
</xsl:template>
-->
      
CDATA Tag: The term CDATA is used about text data that should not be parsed by the XML parser

--> Next just find the class for  class="ms-PostBody"  and add the below script

<!--<xsl:if test="$ShowBody=1">
<div class="ms-PostBody">
<div>
<xsl:apply-templates select="$Fields[@Name='Body']" mode="PrintField">
<xsl:with-param name="thisNode" select="$thisNode"/>
<xsl:with-param name="Position" select="$Position"/>
</xsl:apply-templates>
<script type="text/javascript">
<![CDATA[
$(".ms-PostBody[rendered!='done'] > div > div").each(function(){
if($(this).text().length > 400) {
text = $(this).text().substring(0, 400);
$(this).html(text + "... " + "<a href='" + $(this).parent().parent().parent().find(".ms-PostTitle a").attr("href") + "'>Read More</a>");
}
}).attr("rendered","done");
]]>
</script>
</div>
</div>
</xsl:if>
--> --> Now upload this blog.xsl file into your sharepoint site style library, After that navigate to default.aspx page,edit the blog post webpart and add the xsl file url into "Miscellaneous" secrion--> XSL Link.

http://sitename/Style%20Library/blog_new.xsl

Once the precess is finished your blog posts will looks like this


Thursday, 21 June 2012

Create Web Application with Powershell script

Recently when i am creating SharePoint webapplication using with Central Admin i am facing 'The page can not be displayed' error. If i check with SharePoint webapplicatin it has created but the content database not created properly.

Then i have decided to use simple script for creating new Webapplication in SharePoint.
Below script is for creating New SharePonint Webapplication. ContentDatabase will create automatically for with below script.

New-SPWebApplication -Name "SiteName" -ApplicationPool "ApplicationPoolName" -ApplicationPoolAccount Domain\admin -Port 1133 -URL "http://servername/"