PSAdmin Installation Guide

PSAdmin is an ASP.NET MVC Web Application. It uses an SQLite database for storage.

System Requirements

Prerequisites

I will not go into how to install IIS and the .NET framework as this varies depending on your operating system. You should find all the necessary information on how to install these from the links above or a quick Google.

In order to execute PowerShell scripts using ASP.NET, you first need to ensure that PowerShell is installed (see above link). In later versions of Microsoft's Operating Systems (Windows 7/Server 2008) it is installed by default.

We also need to ensure that the System.Management.Automation assembly is installed. Again, on later versions this is there by default. If not you will need to install it by running the Windows SDK Installer. An easy way of checking to see if the assembly is installed is to browse to C:\Windows\Assembly (the Global Assembly Cache) and searching for System.Management.Automation:

System.Management.Automation installed in the Global Assembly Cache

If you are running PSAdmin on a 32bit machine then you will need the 32 bit version of System.Data.SQLite. The easiest way of installing this is by downloading the installer from http://sqlite.phxsoftware.com/. Once installed you can grab the assembly from the install location and override the 64bit version in the web site's bin directory.

Installing PSAdmin
  • Download the latest release version from http://psadmin.codeplex.com/releases (currently 1.0.0.0 Alpha)
  • Extract the zip archive on your machine
  • Create a new directory for your web site e.g. c:\inetpub\wwwroot\PSAdmin and copy the contents of the install package to it:

PSAdmin installation directory
  • Open up connectionStrings.config in notepad and update the connection string. The connection string name should be the host name of your computer. The connectionString should be the full path to the psadmin database file:

  <connectionStrings>
    <add name="Jasper" connectionString="Data Source=C:\\Inetpub\\wwwroot\\PSAdmin\\App_Data\\psadmin.db;Version=3"/>
  </connectionStrings>
  • Next update the AdminUsers setting in web.config to to include your fully qualified username i.e. domain\username. This is necessary so that when the application runs for the first time you will be added to the administrators group and will therefore be able to access the administrative functions.

  <appSettings>
    <add key="AdminUsers" value="jasper\administrator"/>
  </appSettings>
  • Open up IIS Manager (Start > Run > inetmgr) and make the PSAdmin directory an application (right click the PSAdmin directory and select Convert To Application). Note that the process for making a virtual directory an application is slightly different in IIS6 - if you get stuck then please post to the discussions section

PSAdmin Application Directory in IIS
  • With the PSAdmin application selected in IIS Manager, in the features panel open the authentication settings. Disable anonymous authentication and enable Windows Authentication (since PSAdmin uses Windows Authentication to authenticate users):

PSAdmin Authentication Settings

That should be all that's necessary to get the web site loading. If you navigate to http://localhost/PSAdmin (or whatever you named your web site) PSAdmin should load.

PSAdmin Installed Successfully

Setting the PowerShell Execution Policy

The default Execution Policy in PowerShell doesn't allow you to do much so you will most likely want to set this to RemoteSigned (see http://technet.microsoft.com/en-us/library/ee176949.aspx for details on how to do this)

Enabling Impersonation

So that impersonation can flow between the ASP.NET runtime and the PowerShell runspace (necessary if you wish to enable impersonation on any of your scripts) you need to make a change to the global aspnet.config file.

Open up C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet.config and set alwaysFlowImpersonationPolicy to true:

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
    <runtime>
        <legacyUnhandledExceptionPolicy enabled="false" />
        <legacyImpersonationPolicy enabled="true"/>
        <alwaysFlowImpersonationPolicy enabled="true"/>
        <SymbolReadingPolicy enabled="1" />
    </runtime>
</configuration>

You will then need to reboot your machine for the new setting to be registered.

Sample Scripts

There are a few sample scripts in the psadmin_sample.db file inside the App_Data directory. You can rename this to psadmin.db if you wish to review these scripts.

Last edited Jul 1, 2010 at 4:38 PM by retroviz, version 9

Comments

No comments yet.