Using Powershell – ISE (Integrated Scripting Environment)

February 3, 2014 Leave a comment

A lot of Administrators think that PowerShell is a one-hit-wonder single command tool used to quickly perform a task which can’t be found in the GUI. They couldn’t be further from the truth. Something that very little people know, is that All Operating systems including Server OS since Windows 7 and Server 2008 has a built in PowerShell Debugger and Developer. And the best thing of all is: ITS FREE! . It’s called Windows PowerShell Integrated Scripting Environment. The description “from Microsoft” about this tool is:


This tool as stated above allows you to actually develop your own script-lets which will then be saved as runnable .ps1 files.

I use this tool when I want to write something that will be re-used and paramaterised.

Take note, that the tool is not installed when windows or server is installed out of the box. You have to activate it. To install it :

Open Server manager

Server Manager

Click on Features


Click on Add Features


Scroll down and select Windows PowerShell Integrated Scripting Environment

Select ISE

Click Next and then Install.

You can now find the ISE under > Start > All Programs > Windows PowerShell

Powershell Location

Take note that if you are developing SharePoint related scriptlets, you have to run the 64 bit one.(The one not marked as x86) because SharePoint is a 64bit only Application. Also, always run the application as Administrator as you might run into some nasties if you don’t

The Application opens and you are ready to start writing your script:

Powershell ISE Open

More on the usage of this app in my next blog coming soon.

Using Google Charts in SharePoint

August 13, 2012 Leave a comment

Hi everyone. I recently had to build some charts for a SP Project and for me , the easiest way to get visually attracting and interactive charts, was to use Google charts. Now there are quite a few ways to get Google charts going in SharePoint (example, so I’m sharing my way of doing it and I hope it helps someone else. Disclaimer… I am not claiming that I wrote all this code myself. Some parts are borrowed.

Ok, so here we go:

Firstly, Create a new SharePoint Solution and add a new Visual Web Part. I’m skipping instructions on this but if you don’t know how to do this, I suggest you start with some basic SharePoint development tutorials first.

Open up the User control in your visual web part (the ascx file) and insert the following code:

<!-- This line adds the Google Javascript API to your page -->
<script type="text/javascript" src=""></script>

<!-- Using the Google jsapi, we load the core charts api -->
<script type="text/javascript">
    google.load('visualization', '1', { packages: ['corechart'] });

<script type="text/javascript">
function drawVisualization() {

 // Create and populate the data table.
 // MyArrayData is your array declared on server side
 var ChartData = google.visualization.arrayToDataTable(MyArrayData); 

 //Set all your chart options here.
 var ChartOptions = {
  'title': 'Final gold medal count for 2012 olympics',
  'titleTextStyle': { color: 'black', fontName: '"Verdana"', fontSize: 12 },
  'width': 350,
  'height': 350,
  'backgroundColor': 'white',
  'chartArea': { 'width': '90%', 'height': '70%' },
  'pieSliceText': 'percentage',
  'tooltip': { textStyle: { color: 'black', fontName: '"Verdana"',fontSize:12}},
  'is3D': true

    // Create and draw the visualization.
    new google.visualization.PieChart(document.getElementById('ChartAreaDIV')).
    draw(ChartData , ChartOptions );

<div style="border: 0 none;">
<div id="ChartAreaDIV" style="width: 350px; height: 350px;"></div>

Next up, lets get some data to render. Open the Code behind file for the ASCX, Here is the code for your code behind file:

public partial class TestGoogleChartUserControl : UserControl
    protected void Page_Load(object sender, EventArgs e)
        DemoData demodata = new DemoData();

        //Get the Data - Use your data access layer here
        var data = demodata.GetSomeDemoData();

        //Telling the Array what it's going to hold
            "MyArrayData", "['Label', 'Value']");

        //Register items into a javascript (client side) array
        foreach (var dataitem in data)
                string.Format("['{0}', {1}]", 
public class DemoData
    //Use your Data access layer or some other datasource
    public List<MyDataContract> GetSomeDemoData()
        List<MyDataContract> data = new List<MyDataContract>();
        data.Add(new MyDataContract { 
            ChartItemLabel = "United States", 
            ChartItemValue = 46 });

        data.Add(new MyDataContract { 
            ChartItemLabel = "China", 
            ChartItemValue = 38 });

        data.Add(new MyDataContract { 
            ChartItemLabel = "Great Britain", 
            ChartItemValue = 29 });

        data.Add(new MyDataContract { 
            ChartItemLabel = "Russia", 
            ChartItemValue = 24 });

        data.Add(new MyDataContract { 
            ChartItemLabel = "Korea", 
            ChartItemValue = 13 });

        data.Add(new MyDataContract { 
            ChartItemLabel = "Germany", 
            ChartItemValue = 11 });
        return data;
public class MyDataContract
    //Just a quick data structure 
    //implemention here to make things easier
    public string ChartItemLabel { get; set; }
    public int ChartItemValue { get; set; }                

That’s it. Deploy your web part and it should render a nice little interactive Google pie chart:


Read more on Google charts here:

Find SharePoint Databases not in use

Hiya all

I always find it difficult to keep track of the millions of databases which SharePoint 2010 creates especially when you have multiple different SQL Servers and differnet Sharepoint environments (DEV, UAT, PROD etc).

To this end, I figured out a quick way (Powershell to the rescure) to compare which databases sharepoint still uses and which database server they’re on. I know you can do most of this through Central Admin, but to click on every web application/ service application and compare with SQL takes time.

Now, the command I wrote is not really something new, but most of the other blogs demonstrates a PS command to show the Database name, but that’s not all we want to see now is it? We also need the Database Server.

Ok, so without further Delay, here it is:

Get-SPDatabase | ForEach-Object {$_.DatabaseConnectionString}

This will output all the databases in your farm in a connection string (ASP.Net) format which shows the db name, db server, authentication method etc..

The above PS command will output to the screen, but you can easily output to XML using:

Get-SPDatabase | Export-Clixml -InputObject {$_.DatabaseConnectionString} -Path "c:\ConnectionSTrings.xml

So that’s it. The beauty of Powershell. Hope this helped you.


Get every new post delivered to your Inbox.

%d bloggers like this: