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
2009-06-25 12:48:01
Sweet! Thanks mate!
Matthew
2009-06-25 13:17:47
No probs :)
Kev
2009-06-25 13:18:42