views:

114

answers:

1

I'm configuring a web site using PowerShell and I want to set the default document. How do I do this?

+1  A: 

This is one way:

$metabasePath = "IIS://Localhost/W3SVC"
$iisNumber = "12345"
$site = new-object 
        System.DirectoryServices.DirectoryEntry("$metabasePath/$iisNumber/root")
$site.psbase.Properties["DefaultDoc"].Value = 
    "newdefdoc.htm," + $site.psbase.Properties["DefaultDoc"].Value
$site.psbase.CommitChanges()

The value returned in $site.psbase.Properties["DefaultDoc"].Value is a comma separated list of documents so you may need to re-jig the order to suit your case. The example above just adds a new default document (newdefdoc.htm) to the top of the list.

Kev
Sweet! Thanks mate!
Matthew
No probs :)
Kev