Site.RevertToParent Method [IIS 7 and higher]

Reverts a Web site configuration value or values to the default.

Syntax

Site.RevertToParent(PropertyName)
Site.RevertToParent(PropertyName);

Parameters

Name

Description

PropertyName

An optional string value that contains the name of the Web site property that is to be reverted to the default specified by SiteElementDefaults. The property can be nested (for example, "LogFile.Directory").

Return Value

This method does not return a value.

Remarks

When you call RevertToParent without parameters, all custom configuration values for the Web site will be removed. If this is not the behavior you want, revert specific properties by using parameterized calls to the method.

Example

The following example reverts the default Web site's log file directory from %SystemDrive%\MySiteLogFiles to %SystemDrive%\inetpub\logs\LogFiles. The example makes this change in the <logFile> section for the default Web site in the ApplicationHost.config file.

Note

The LogFile property of the Site class contains an instance of the SiteLogFile class. The SiteLogFile instance has a Directory property. You specify this nested property by using oSite.RevertToParent("LogFile.Directory").

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
    "winmgmts:root\WebAdministration")

' Retrieve the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")

' Display the Web site name, ID, and log file directory.
WScript.Echo "Web site name: " & oSite.Name
WScript.Echo "Site ID: " & oSite.ID    
WScript.Echo "Log file directory before revert: " & _
    oSite.LogFile.Directory

' Revert the log file directory to the default.
oSite.RevertToParent("LogFile.Directory")

' Update the contents of the oSite object variable.
oSite.Refresh_

' Display the change.
WScript.Echo _
    "Log file directory after revert: " & _
        oSite.LogFile.Directory

' Example output:
' Web site name: Default Web Site
' Site ID: 1
' Log file directory before revert: %SystemDrive%\MySiteLogFiles
' Log file directory after revert: %SystemDrive%\inetpub\logs\LogFiles

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

Site Class [IIS 7 and higher]

SiteLogFile Class [IIS 7 and higher]

SiteElementDefaults Class [IIS 7 and higher]