Thursday 27 November 2014

Get Site Template GUID using Powershell

Sometimes we need to find the GUID of save site template.

Open Power shell management shell in administrator mode.
 here is the power shell script that provide you the functionality. pate it.

 $url = "http://localhost:mysite/"

$site= new-Object Microsoft.SharePoint.SPSite($url )

$loc= [System.Int32]::Parse(1033)

$templates= $site.GetWebTemplates($loc)

foreach ($child in $templates){ write-host $child.Name "  " $child.Title}

click Enter. And you will get the list of site template with the GUID.

Friday 21 November 2014

How to delete the unused application pool From IIS?

Recently I had issue with user profile service. I delete it and try to recreate it. That time I got an error
An object of the type Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool named "User Profile Service App Pool" already exists under the parent Microsoft.SharePoint.Administration.SPIisWebServiceSettings named "SharePoint Web Services".  Rename your object or delete the existing object.

So I search for the resolution of the issue. I got two options
1. They say Try a  different name. - Which didn't help in my case.I would say try your luck also.
2. Delete current app pool and try again to create.

So here is the process:

IIS will not provide the interface for managing service application's application pools. But we can delete service application's application pool in SharePoint 2010/2013  using powershell.

Use these below cmd-let to get list of service application's application pools.

SharePoint 2010/2013 delete orphaned application pool: To delete a application pool of service application, use the cmdlet:

 1. Run "Sharepoint Management Shell " in administrator mode.
 2. Type "Get-SPServiceApplicationPool". It will give you list of app pool.
 3. Type "Remove-SPServiceApplicationPool". 
 4. It will ask you identity. Give the app pool name you want to remove from above list. Try not to make  spell mistake.
 5. Click Enter.
 6.It will ask for confirmation. Type "y". click Enter.

Thursday 20 November 2014

Linq query to datatable conversion

Recently I have encounter with Linq after a long time and I was required to convert linq result in to datatable. It take a while but I found the method i used in past. I hope it will help you too.

 1. use AsEnumerable() in your query.and you will be good to get a function CopyToDataTable() to get datatable.
var query =
    from order in orders.AsEnumerable()
    join detail in details.AsEnumerable()
    on order.Field<int>("SalesOrderID") equals
    where order.Field<bool>("OnlineOrderFlag") == true
    && order.Field<DateTime>("OrderDate").Month == 8
    select new
        SalesOrderID =
        SalesOrderDetailID =
        OrderDate =
        ProductID =

DataTable orderTable = query.CopyToDataTable(); 
Original Source :

2. use this coustom method to get datatable

public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
     if (query == null)
          throw new ArgumentNullException("query");
     IDbCommand cmd = ctx.GetCommand(query as IQueryable);
     SqlDataAdapter adapter = new SqlDataAdapter();
     adapter.SelectCommand = (SqlCommand)cmd;
     DataTable dt = new DataTable("sd");

          adapter.FillSchema(dt, SchemaType.Source);
     return dt;

For getting datatable

var vr = from country in objDataContext.CountryMaster
                        select new {country.CID,country.CName};

DataTable dt = ToDataTable(objDataContext,vr);

Original source :

Monday 17 November 2014

On-screen Keyboard in Windows

Sometimes soon we will have a touchscreen desktops in our work premises. If you want a on screen keyboard here are some shortcuts

Click the Start menu, point to All Programs, point to Accessories, point to Accessibility, and then click On-Screen Keyboard to open On-Screen Keyboard.
(link -

 2. My way start -> run -> type "osk". click ok. you can create shortcut on desktop writing osk in shotcut. and click on it.