Browsed by
Tag: Scripts

PowerShell Script: SharePoint Farm Creation

PowerShell Script: SharePoint Farm Creation

For a long time I have been meaning to rewrite the PowerShell script that I have been using to do my SharePoint farm creation and just haven’t gotten around to completing the necessary effort to make it all that I want it to be. I have leveraged the work of others, borrowing a piece here and a snippet there but to honest I haven’t been satisfied.

What I really wanted was a script that I can use in my consulting practice as a normalized practice of how a farm should be deployed as well as a script that I could use in the highly repetitive process of doing ITPro dev work. I wanted something that was flexible enough to use for client installs, but repeatable enough that I could use it in my dozens of farm builds that I do in my spare time for troubleshooting and fun.

Here are the key points of what I did differently with this script:

  1. use temporary variables that can be accepted or overridden at the PowerShell command-line when the script is called
    SNAGHTML37d3721b
  2. validate if the pieces have been implemented correctly & gives information about what piece failed, not just throwing the ugly PowerShell errors that we are used to seeing
    SNAGHTML37d4db9e
  3. validate that you are using PowerShell running as Administrator to ensure that you won’t fail for that silly reason
    SNAGHTML37d64475
  4. pulls the system & domain variables rather than having to set those parameters manually
    SNAGHTML37d7b73f

I am happy to report that I was able to accomplish all of these things in my script and am happy to offer it up for others to use if you see fit. I highly recommend that you consider using the PowerShell profile that I laid out in my previous article “How to: Automatically log your PowerShell session everytime” so that you can, among other things, capture the output of building your farm.

There are very few people who can honestly say that they created their PowerShell scripts completely from scratch, and I am certainly not among them. Credit is due for snippets & reference to Shannon Bray, Gary LaPointe, Brian Lalancette, Todd Klindt, & I’m sure others. Special appreciation to Evan Riser for helping me QA this script. 

One last thing to note about this script… it does just what it says it does. It creates a SharePoint farm.  This is not an all inclusive build your farm & configure every setting script. If you are looking for the all inclusive, über build & configure script please go visit Brian’s codeplex project: AutoSPInstaller. There is no need for anyone to recreate the amazing work that he has done. 

The reason I create this scripts like this is that I prefer to break my scripts down into pieces and keep them highly modular. This is partly because I consult on such a wide variety of projects that it makes my life easier to be able to deploy pieces at a time using different scripts. It also could be that I am a neurotic, lunatic control freak who is a bit over obsessed with developing in PowerShell for fun.  Hopefully it’s more the first thing than the second thing… 🙂

I will continue to publish the scripts that I find useful here in the hopes that it helps someone else along the way. You can find my SharePoint Farm Creation PowerShell script here on my SkyDrive.