Dev Notes

Notes on Development with Microsoft Technologies

PowerShell – Great for Documentation

Leave a comment

Today, I needed to quickly make some documentation for a client to show them how many content databases they have and the total number of site collections that currently exist in their environment. PowerShell came to the rescue beautifully and helped me solve the problem.

First, I wanted to know what PowerShell commands were available to me, so I located a blog post by Adam Preston detailing how to dump all of the commands to a text file. Once you have the commands, you can make use of PowerShell’s Get-Help command to get the syntax and description of the command.

Armed with this, I discovered the Get-SPContentDatabase commandlet that iterates over all the available content databases in the farm. Executing Get-SPContentDatabase without any parameters will return every content database in the farm. However, the list format was not the desired format.

Further research lead me to create my own table format:

$a = @{Expression={$_.Name};Label=”Database Name”;width=70},@{Expression={$_.CurrentSiteCount};Label=”Sites”;width=10}

This format makes sure there is plenty of room for a long database name and then gives the ability to show how many site collections are in the database. Now, my command is:

Get-SPContentDatabase -WebApplication | format-table $a > ContentDatabases.txt

When the command completes, I can simply open up the text file and begin my documentation.


Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s