DNNTipsandTricksOver the last 5 years I have literally installed DotNetNuke hundreds of times on my local development machines.  During this time installation has gotten easier, but it still takes a few minutes and is still subject to mistakes being made.  Also, because there are several steps involved, I often take shortcuts.  This is ok when I am just throwing up development instances, but it is counterproductive when I am trying to do actual testing of a beta or release candidate.

Last fall I started building a series of PowerShell scripts for simplifying the process.  Although there are installers available for DotNetNuke, they are often out of date and are fairly rigid in how they perform the install.  Using PowerShell provides a lot of advantages over a traditional installation program.  I have complete control over the installation in an interactive environment and can change any one of dozens of parameters that control the installation.

In my first posting on PowerShell and DotNetNuke I outlined the following steps for installing DotNetNuke and showed how I performed the first step using PowerShell.

  1. Unzip the DNN package to my website directory.
  2. Set permissions for the "Network Service" Account
  3. Create a blank database
  4. Create a user account in the database
  5. Create the Web Application in IIS
  6. Run the DotNetNuke web-based installer

Since that first post, I have filled out my scripts so that I now have every step automated and the process is much simpler.

Script NameDescription
AclLib.ps1 Contains the function for setting permissions on files and folders.
DbLib.ps1 Contains functions for managing a database.  These functions rely on SQL Management Objects (SMO) to perform tasks.
IELib.ps1 This includes functions for opening a webpage and invoking the DNN Install Wizard.
IISLib.ps1 Contains functions for listing and creating web-applications.  These functions are currently specific to IIS7 (Vista and Windows 2008).
SecurityLib.ps1 Contains a function to determine if scripts are running with elevated permissions.
ZipLib.ps1 Contains functions for extracting zip files using Windows shell.
Install-DNN.ps1 Contains a function that encapsulates the entire installation process.  This function contains many of the standard conventions so that the function call can be short.

To use the individual scripts you need to load them into your PowerShell console.  You can do this by “dot sourcing” the script which will load the included functions and make them available for use. Using the individual scripts you can enter PowerShell commands to perform any step listed above.  Lets look at an example of using the scripts to create a new database.

   1:  . .\DBLib.ps1
   2:   
   3:  $conn = new-dbconnection -integratedsecurity 
   4:  $database = new-database $conn "TestDB" 

In this example, I have used created a new server connection and then used that connection to create the database.  Using the individual functions allows me to create a database that does not follow my standard database naming convention.

The video below shows the scripts in action.  Using the scripts you can have a new DotNetNuke installation up and running in under 5 minutes.

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 

The scripts for this post have been added to the Posh4DNN project at CodePlex.