Sharepoint 2010 powershell references

February 2, 2012 Leave a comment

export-and-importcreate-site-columns :

Get all Site Columns for a SharePoint 2010 site collection:

How to: Add a Content Type to a Site:

Export Content Types:

Categories: General Tags:

Log files and TextWriterTraceListener

February 1, 2012 2 comments

Writing a log file using TraceListner classes its just one more way of writing logs..ย  ๐Ÿ™‚

private int Logger(Exception exObj)
using (Stream myFile = File.Exists(“TestFile.txt”) ? File.Open(“TestFile.txt”, FileMode.Append) : File.Create(“TestFile.txt”))
/* Create a new text writer using the output stream, and add it to * the trace listeners. */
TextWriterTraceListener myTextListener = new TextWriterTraceListener(myFile);
// Write output to the file.
Trace.Write(“\r\n Test output \r\n”);
Trace.Write(“\r\n Test output \r\n”);

// Flush the output.

Trace.Listeners.Remove(myTextListener); // this is very important else you may encounter error wrt file/stream/trace object
return 0;

Categories: General Tags: , ,

Get dataset from xml document using XmlNodeReader

February 1, 2012 1 comment

Hi, many times we need to read an xml file and get it in either dataset or datatable. This is ok till we directly use dataset.readXML method, but what when we just need to read specific nodes (infact elements) and then create dataset/datatable out-of it? (quite tricky right)

The answer is create an XmlNodeReader object and get the required element (node) into it either by traversing the xml document or by firing a simple (yet powerful) XPath Query on to the document.ย  The below sample explains the same by making use of Xpath Query.

private void btnGetData_Click(object sender, EventArgs e)
//Create xmlnode and xmlElement for xpath
XmlNode xmlNode;
XmlElement root = doc.DocumentElement;

// xpath expression //List[@Name=’Lotus Machines’]
xmlNode = root.SelectSingleNode(txtExpression.Text);

DataSet dataSet = new DataSet();
if (xmlNode.HasChildNodes)
for (int indexNode = 0; indexNode < xmlNode.ChildNodes[0].ChildNodes.Count; indexNode++)
XmlNode innerNode = xmlNode.ChildNodes[0].ChildNodes[indexNode];
using (XmlNodeReader reader = new XmlNodeReader(innerNode))
{// fill dataset from reader object as below ๐Ÿ™‚

I would definitely like to hear from ur side if there is any other better way for so… till the bye byeย  ๐Ÿ™‚

2011 in review

January 7, 2012 Leave a comment

The stats helper monkeys prepared a 2011 annual report for this blog.

Here’s an excerpt:

A New York City subway train holds 1,200 people. This blog was viewed about 5,300 times in 2011. If it were a NYC subway train, it would take about 4 trips to carry that many people.

Click here to see the complete report.

Categories: General

Heavy shelling with powershell

August 10, 2011 Leave a comment

in this post i’m going to cover the powershell as what i understood. hope you all find it appropriate and worth for your work. if not than please do feel free to update / upgrade my knowledge :).

So starting with shelling ๐Ÿ™‚

what is powershell:
* windows powershell is microsofts task automation framework [as per wikipedia] built primarily for the windows administrators.
* It basically consist of command-line shell which is build on top of .net common language runtime and .net framework that accepts and returns .NET framework objects unlike to its counterparts which accept and return text.
* An administrator can perform administrative tasks on local but also on remote windows system through the virtue of powershell support to COM and WMI

As per microsoft its:

I came across some handy tool / editor for playing with the powershell at http://powergui.orgย  do check it.

Manish Patil

Categories: General Tags:

Manipulating SharePoint Lookup Field values using Javascript

May 31, 2011 1 comment

This article gives an small trick for manipulating the values of SharePoint Lookup Field (OOB control for list item lookup). For one of my assignments I was required to manipulate the values listed into SharePoint Lookup Field so I did it in this fashion ๐Ÿ™‚

function getField(fieldType,fieldTitle)
var docTags = document.getElementsByTagName(fieldType);
for (var i=0; i < docTags.length; i++)
if (docTags[i].title == fieldTitle)
docTags[i].readOnly = true;
docTags[i].setAttribute(“choices”,”Comment 1|20″);
return false;
getField(‘input’,’Comment Type’);

Categories: General Tags:

Add .net assembly to sharepoint 2010 package or solution

April 5, 2011 Leave a comment


here in today I would like to share a small but required thing while packaging sharepoint solutions. We usually require to bundle-up .net assemblies within a sharepoint solution(s). Microsoft Visual studio 2010 has made this thing very easy for packaging sharepoint 2010 solutions.

Please check the screen shots for the sameIn the solution explorer you can see an .net assembly( underlined red in color), I wanted to refer/add this assembly into the sharepoint solution (highlighted in dark black).

So I opened the package.package (double click it ๐Ÿ™‚ ) as shown in screen shot.

Here on the wizard click on Advance tab (highlighted in red box below)

On opening of the tab gives option (inform of buttons) to add, edit, delete “Additional Assemblies”. The added assemblies are listed in the grid.

When we try to add new assembly it will give 2 options viz; Add existing assembly & Add assembly from project output

Now if you want to add assembly from your current project/solution then use second option & if you to refer to external assembly which is not part of your project then use first option.

In either cases if you want to register these assemblies into the web.config safe controls then there is provision for same ๐Ÿ™‚

One most important thing to remember is: any assembly that you want to refer/add should be strong named (public token key) in order to add it to the GAC / assembly cache.

Additional Resource can be found at: Add & Remove Additional Assemblies