Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Removes the specified element from a collection in a configuration section.
Syntax
ConfigurationSectionWithCollection.Remove collectionName, element;
ConfigurationSectionWithCollection.Remove collectionName, element
Parameters
Name | Definition |
---|---|
collectionName |
A string value that specifies the name of the collection that has an element to be removed. |
element |
A CollectionElement object that contains the element to be removed. |
Return Value
This method does not return a value.
Example
The following example displays the names of the handlers for the default Web site, removes the handler element named "CGI-exe" if it is present, and then lists the handler names again. The code will cause the following XML to be added to the <system.webServer>
section of the Web.config file for the default Web site:
<handlers>
<remove name="CGI-exe" />
</handlers>
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
' Get the handlers section.
oSite.GetSection "HandlersSection", oHandlersSection
' Display the current handler names.
Wscript.Echo "---[Current Handler List]---"
Call DisplayHandlerNames
' Remove the CGI-exe handler by matching its name.
For Each oHandler In oHandlersSection.Handlers
If oHandler.Name = "CGI-exe" Then
oHandlersSection.Remove "Handlers", oHandler
End If
Next
' Refresh the oHandlersSection object so that its contents will
' reflect the updated configuration.
oHandlersSection.Refresh_
' List the handler names again to show the change.
Wscript.Echo "---[New Handler List]---"
Call DisplayHandlerNames
' Provide a subroutine to display handler names.
Sub DisplayHandlerNames
For Each oHandler In oHandlersSection.Handlers
WScript.Echo "Handler Name: " & oHandler.Name
Next
Wscript.Echo
End Sub
Note Calling the Remove_
method updates the underlying configuration store but not the oHandlersSection
object that is running in memory. Calling the Refresh_
method on oHandlersSection
will ensure that its data is accurate if you need to use it later in the same script.
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
ConfigurationSectionWithCollection Class
HandlerAction Class
HandlersSection Class