ConfigurationSection.RevertToParent Method

Reverts configuration values in a section to their defaults.

Syntax

ConfigurationSection.RevertToParent();  
ConfigurationSection.RevertToParent(PropertyName);  
ConfigurationSection.RevertToParent  
ConfigurationSection.RevertToParent(PropertyName)  

Parameters

Name Definition
PropertyName An optional string value that contains the name of a property in the configuration section. The property can be nested (for example, oLogSection.RevertToParent("CentralBinaryLogFile.Directory").

Return Value

This method does not return a value.

Remarks

This method provides a way to delete configuration values that have been written to a configuration file.

Example

The following example shows two ways of using the RevertToParent method:

  1. The first part reverts a specified property to the default value. The following line from the example reverts the Enabled property of DefaultDocumentSection of the default Web site by specifying the property name as a RevertToParent parameter.

    oDefaultDocumentSection.RevertToParent("Enabled")  
    

    This removes the value of false, which was specified in the Web.config file of the default Web site, and replaces it with the default value of true.

  2. The second part reverts an entire section to the default values. The following line from the example reverts the entire DefaultDocumentSection contents of the default Web site by specifying no parameters for RevertToParent.

    oDefaultDocumentSection.RevertToParent  
    

    This removes all values from the default document section in the Web.config file of the default Web site. The default values of the default Web site replace the removed values.

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the DefaultDocumentSection for the Default Web Site.  
Set oSite=oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "DefaultDocumentSection", oDefaultDocumentSection  
  
' 1. Revert the Enabled property to its default value.  
oDefaultDocumentSection.RevertToParent("Enabled")  
  
' 2. Revert the entire default document section.  
oDefaultDocumentSection.RevertToParent  
  

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

ConfigurationSection Class
ConfigurationSectionWithCollection Class
ConfiguredObject Class
DefaultDocumentSection Class