Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Iiscnfg.vbs IIS configuration script

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use Iiscnfg.vbs IIS configuration script", the content of the article is simple and clear, easy to learn and understand, please follow the editor's ideas slowly in depth, together to study and learn "how to use Iiscnfg.vbs IIS configuration script" bar!

Import and export all or selected elements of the Internet Information Services (IIS) configuration database on a local or remote computer, or copy the entire IIS configuration (configuration database and schema) to another computer to copy the configuration. Iiscnfg performs the following functions:

To view the command syntax, click the following command:

Iiscnfg / export

Copy all or part of the IIS configuration database to an XML file in an encrypted or unencrypted format. You can then use the XML file during the import operation to copy all or part of the configuration database to other IIS configurations.

Grammar

Iiscnfg [.vbs] / export / f [Path] FileName.xml / sp MetabasePath [/ d EncryptingPassword] [/ inherited] [/ children] [/ s Computer [/ u [Domain] User [/ p Password]

Parameters.

/ f [Path] FileName.xml

Necessary. Specifies the unique name and location of the exported file. This command fails if you specify an existing file or if a directory in the specified path does not exist.

The file path must be local. If you export a file from a remote computer, the / f parameter refers to a path on the remote computer.

/ sp MetabasePath

Necessary. Specifies the configuration database key to export. Enter the configuration database path to identify the selected key.

/ d EncryptingPassword

Encrypts the export file with the specified password. You can use any string as the password.

The / d parameter creates a secure export file by encrypting the session key and security attributes with the specified password. You must provide a password to use this file in the Import operation.

If this parameter or password parameter is omitted, the exported file is encrypted with a blank password. In this way, only security attributes are encrypted, and any administrator can use the export file to import the configuration database configuration.

/ inherited

Add the inherited properties of the exported key to the export file. Without this parameter, the export file does not include properties inherited from higher-level keys.

/ children

Recursively adds the subkey of the specified key to the exported file.

/ s Computer

Runs the script on the specified remote computer. Type the computer name or IP address without a backslash. By default, scripts are run on the local computer.

/ u [Domain] User

Run the script with the privileges of a specific user account. The account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user on the local computer.

/ p Password

Specifies the password for the user account specified in the / u parameter. If you omit this parameter, the script prompts you for a password and hides the typed text.

/?

Displays help at the command prompt.

Annotation

■ to perform this process, you must be a member of the local computer Administrators group, or you must be delegated the appropriate permissions. If you join a computer to a domain, members of the Domain Admins group may also be able to perform this process. As the best practice for security, you can consider using the mode of operation to perform this process.

■ uses quotation marks to enclose configuration database path elements that contain spaces. Enclose only elements with spaces, not the entire path. For example, type "Default FTP Site" / IISAdmin instead of "Default FTP Site/IISAdmin".

Example

The following example shows how to use iiscnfg / export in specific situations.

Export site configuration

The following command exports the configuration of the Finance Web site to a C:FinanceFinance.xml file. This command uses the / sp parameter to specify the configuration database path / lm/W3SVC/2 of the Web site, and the / children parameter to export all configured subkeys. It also uses the / inherited parameter to include inherited properties in the exported file. This will ensure that the site configuration retains these properties, even if it is imported to a different system.

Iiscnfg / export / f c:financefinance.xml / sp / lm/w3svc/2 / children / inherited

In response, Iiscnfg.vbs displays the following success message:

Configuration exported from / lm/w3svc/2 to file c:financefinance.xml

The result file will include all keys and subkeys in the / lm/w3svc/2 path. It also includes an IisInheritedProperties key that contains the values of all inherited properties.

Export the entire IIS configuration of the local computer

The following command exports the IIS configuration of the local computer to a D:IIStestConfig.xml file. It uses the / f parameter to specify the file name and location, and the / sp parameter to specify the root key (/) of the configuration database. The / children parameter adds all subkeys of the root key recursively to the export file. (if there is no / children parameter, only the root key is exported. Finally, the command encrypts the export file with the / d parameter and password.

Iiscnfg / export / f d:iistestconfig.xml / sp / / children / d p@sswoRd61

In response, Iiscnfg.vbs displays the following success message:

Path / has been exported to d:iistestconfig.xml

Note that even if the configuration is fully exported, it is different from the system's Metabase.xml file. The session key, access control list (ACL), and password are all different.

In addition, it is impossible to tell whether it is encrypted or not just by looking at the exported file. However, if you compare the encrypted and unencrypted versions of the same file, you will find that the values of the security properties in the encrypted version have changed. Therefore, if you do not have a password, the file cannot be used with the import command.

Iiscnfg / import

Add the configuration settings of the XML configuration database export file to the configuration database of the IIS server.

Grammar

Iiscnfg [.vbs] / import / f [Path] FileName / sp SourcePath / dp DestinationPath [/ d EncryptingPassword] [/ children] [/ inherited] [/ merge] [/ s Computer [/ u [Domain] User [/ p Password]

Parameters.

/ f [Path] FileName

Necessary. Specify the path and file name of the XML source file.

The file path must be local. When you import a file to a remote computer, the / f parameter refers to a path on the remote computer.

/ sp SourcePath

Necessary. Specifies the location of the key being imported in the XML file. When the key appears in the XML file, enter its configuration database path. To import all keys in the source file, enter the configuration database path for the root key.

/ dp DestinationPath

Necessary. Specifies where to place the import key in the configuration database. Enter the configuration database path.

If the specified path already exists in the configuration database, the import key overwrites and replaces the key currently in the configuration database path without any warning.

/ d EncryptingPassword

Specifies the password used to encrypt configuration data.

This parameter is required to encrypt the configuration file. If no password is provided to encrypt the file, or if an incorrect password is provided, this command will fail.

/ children

Imports the subkey of the specified key recursively.

/ inherited

Import the inheritance properties of the key. This parameter is valid only if the source file includes inherited properties.

/ merge

Merge the key in the XML file with the existing configuration database key. Without this parameter, the key in the XML file replaces the existing key in the same configuration database path.

The / merge parameter adds keys that appear only in the XML file to the configuration database, keeps keys that are not in the XML file in the configuration database, and applies the values in the XML file when the keys appear in both the XML file and the configuration database.

/ s Computer

Runs the script on the specified remote computer. Type the computer name or IP address without a backslash. By default, scripts are run on the local computer.

/ u [Domain] User

Run the script with the privileges of a specific user account. The account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user on the local computer.

/ p Password

Specifies the password for the user account specified in the / u parameter. If you omit this parameter, the script prompts you for a password and hides the typed text.

/?

Displays help at the command prompt.

Annotation

■ to perform this process, you must be a member of the local computer Administrators group, or you must be delegated the appropriate permissions. If you join a computer to a domain, members of the Domain Admins group may also be able to perform this process. As the best practice for security, you can consider using the mode of operation to perform this process.

■ uses quotation marks to enclose configuration database path elements that contain spaces. Enclose only elements with spaces, not the entire path. For example, type "Default FTP Site" / IISAdmin instead of "Default FTP Site/IISAdmin".

The key imported by ■ must be the expected type in the new location in the configuration database path. If the key is of an unexpected type, the configuration will not function properly. For example, do not import the event logging configuration (/ LM/Logging) into the site configuration path, such as / LM/W3SVC/3.

Changes made by ■ using Iiscnfg.vbs take effect immediately. When the file is updated (every 5 seconds or every 50 changes), these changes are reflected in the MetaBase.xml file.

Example

The following example shows how to use iiscnfg / import in specific situations.

Import a Web site from an export file

The following command imports the NewSite site configuration from the C:Config.xml file to the configuration database.

This command uses the / f parameter to specify the name and location of the source file. It uses the / sp (source path) parameter to indicate the location of the key to be imported in the Config.xml file. At this point, the NewSite configuration will be in the / lm/w3svc/5 path of the Config.xml file. It then uses the / dp (target path) parameter to specify the location of the configuration database where the import key should be placed. At this point, the NewSite configuration key should be imported into the / lm/w3svc/3 location in the configuration database. Finally, it will use the / children parameter to include the subkey of / lm/w3svc/5 in the import operation. If there is no / children parameter, only the site root is imported.

Keep in mind that the / import operation overrides without warning. If the configuration database already has keys at the / lm/w3svc/3 location, those keys will be replaced by the import keys.

Iiscnfg.vbs / import / f c:config.xml / sp / lm/w3svc/5/Root/NewSite / dp / lm/w3svc/3 / children

In response, Iiscnfg.vbs displays the following success message:

Configuration imported from / lm/w3svc/5 in c:config.xml to / lm/w3svc/3 in the Metabase.

After using this command, the NewSite configuration appears in the IIS of the third website with the configuration database path of / lm/W3SVC/3.

Import logging configuration to a remote computer

The following procedure imports the custom logging configuration from C:IISLogging.xml into the IIS configuration database on the remote computer. You can use this method or an extension of the method to propagate the configuration to a set of servers.

The steps to import the logging configuration to the remote computer are two steps:

1. Copy the source file to the remote computer. (Iiscnfg.vbs does not allow remote paths in the / f parameter. )

two。 Import the configuration into IIS.

The first command copies the Iislogging.xml file to the remote server Svr126:

Copy IISLogging.xml\ Svr126c$

The second command imports Iislogging.xml into the IIS configuration of Svr126. It uses the / f parameter to identify the source file, the / sp parameter to specify the path to the / LM/Logging/Custom Logging configuration database to import, and the / dp parameter to place the import key in the same location as the target configuration / LM/Logging/Custom Logging. Enclose path elements that contain spaces in quotation marks. ) it uses the / children parameter to import all subkeys of the logging key.

To operate on Svr126, it uses the / s parameter to specify the remote computer and the / u and / p parameters to run scripts with user administrator account privileges on the remote computer.

Iiscnfg / import / f C:IISLogging.xml / sp "/ lm/logging/custom logging" / dp "/ lm/logging/custom logging" / children / s Svr126 / u Svr126Administrator / p p@ssword1#

In response, Iiscnfg.vbs displays the following success message:

Connecting to the server. Done. Configuration imported from / lm/logging/custom logging in file C:IISLogging.xml to / lm/logging/custom logging in the Metabase. As a result of http://blog.const.net.cn/a/615.htm, the / LM/Logging/Custom Logging key and its subkeys are copied from the local configuration database to the Svr126 configuration database.

Merge a virtual directory with a website

This example illustrates how the / merge parameter works by comparing the standard import operation with the import operation that uses the / merge parameter.

Both commands use the same import file Invest_vdir.xml to update the properties of the Investments virtual directory of the Web site.

The following example shows how Investments configures the database key before running any import operation. (this example is obtained from a backup copy of the configuration database created using Iisback.vbs.)

Configuration database before import

The following example shows the contents of the Invest_vdir.xml file that will be used in the import operation. (this example is created by exporting the Investments configuration database key and then editing the export file. )

Notice that the following properties of the Investments key have changed in the XML file:

The value of the ■ AccessFlags property has changed.

■ added the AuthFlags attribute.

■ omits the DirBrowseFlags attribute.

Import file contents

Command 1: standard Import

The following command imports the Invest_vdir.xml file into the configuration database without using the / merge parameter. This command instructs IIS to replace the Investments key in the configuration database with the key of Investments in the XML file.

This command uses the / f parameter to specify the import file and uses the same configuration database path in the source path (/ sp) and destination path (/ dp) parameters.

Iiscnfg / import / f e:iistestInvest_vdir.xml / sp / LM/W3SVC/1509060625/root/Investments / dp / LM/W3SVC/1509060625/root/Investments

After using this command, the Investments key in the configuration database will be the same as the Investments key in the Invest_vdir.xml import file.

Command 2: import and merge

The following command merges the Investments keys from the Invest_vdir.xml file into the configuration database. The / merge parameter instructs IIS to add new attributes from the import file to the configuration database, leave the configuration database properties that are not in the import file unchanged, and apply the import file values when the attributes appear in both the import file and the configuration database.

This command is the same as command 1 except for the addition of the / merge parameter.

Iiscnfg / import / f e:iistestInvest_vdir.xml / sp / LM/W3SVC/1509060625/root/Investments / dp / LM/W3SVC/1509060625/root/Investments / merge

After using this command, the contents of the Investments keys in the configuration database are a combination of their sources, as shown in the following example.

Notice that the following properties of the Investments key in the configuration database have changed:

The value of the AccessFlags property that ■ displays in the configuration database and XML file has changed. The values in the XML file now appear in the configuration database.

■ has added an AuthFlags attribute that appears only in the XML file.

Only the DirBrowseFlags property that ■ displays in the configuration database has not changed.

Iiscnfg / copy

Copy the IIS configuration database and schema from one computer to another.

Grammar

Iiscnfg [.vbs] / copy / ts TargetComputer / tu TargetUser / tp TargetPassword [/ s Computer [/ u [Domain] User [/ p Password]

Parameters.

/ ts TargetComputer

Necessary. Copies the IIS configuration database to the specified computer. Type the IP address or computer name (without a backslash).

/ tu TargetUser

Necessary. Specifies the account used to connect to the target computer. Type the user account in [Domain] User format. The account must be a member of the Administrators group on the target computer.

This parameter is required even if the current user of the local computer is the administrator of the target computer.

/ tp TargetPassword

Necessary. Specifies the password for the account specified by the / tu parameter.

/ s Computer

Copies the IIS configuration database on the specified remote computer to the target computer. This parameter runs the script on the remote computer. Type the remote computer name or IP address (without a backslash). The default value is the local computer.

/ u [Domain] User

Run the script with the privileges of a specific user account. The default value is the current user on the local computer. If the current user is not an administrator of the remote computer, you must use this parameter.

/ p Password

Specifies the password for the user account specified in the / u parameter. If you omit this parameter, IISCnfg prompts you for a password and hides the text you typed.

/?

Displays help at the command prompt.

Annotation

■ to perform this process, you must be a member of the local computer Administrators group, or you must be delegated the appropriate permissions. If you join a computer to a domain, members of the Domain Admins group may also be able to perform this process. As the best practice for security, you can consider using the mode of operation to perform this process.

■ by default, IISCnfg copies the configuration database of the local computer to the target computer specified by the / ts parameter. However, you can use the / s parameter to copy the configuration database from another computer to the target computer.

The ■ replication operation uses IISBack.vbs to create backup copies of the source configuration database and schema. It then copies the backup copy files (.MDX and .SCX) to the target computer and uses the backup copy through IISBack.vbs to replace the configuration database and schema of the target computer. Although these operations can be done manually, the IISCnfg replication operation provides a convenient one-step way to copy the IIS configuration.

■ this copy operation does not copy server content related to the IIS configuration, such as web pages and FTP files.

The ■ replication operation changes the computer-specific and system-specific properties in the configuration database so that they are valid on the target computer. However, it does not adjust the directory or file path. In this way, the path in this configuration may not be valid on the target computer.

Example

The following example shows how to use iiscnfg / copy in specific situations.

Copy the IIS configuration of the local computer

The following command copies the IIS configuration of the local computer to the SVR01 server. This command uses the / ts parameter to identify the target server and the / tu and tp parameters to provide the user's administrator account and password on the SVR01 server.

Iiscnfg / copy / ts SVR01 / tu SVR01Admin06 / tp P@ssWord6

In response, Iiscnfg.vbs displays the following success message.

Backing up server 127.0.0.1 Backup complete. The IP address 127.0.0.1 is a loopback address, which generally refers to the local computer. This address is used only when copying the configuration of the local computer.

Copy the IIS configuration of a remote computer

The following command copies the IIS configuration of the remote computer SRV06 to the MAINBKP server. This command uses the / s command to identify the remote computer and the / u parameter to provide the user's administrator password on the SRV06 computer. It also uses the / ts parameter to identify the target server and the / tu and tp parameters to provide the user's administrator account and password on the MAINBKP server.

Unlike the optional / p parameter, the / tp parameter is required. If you omit this parameter, the command will fail.

Iiscnfg / copy / s SRV06 / u Domain01Admin01 / ts MAINBKP / tu MAINBKPAdmin01 / tp P@ssWord6

In response, Iiscnfg.vbs prompts for the account password specified by the / u parameter. (it does not echo password characters typed. Then, after confirming the password, it copies the configuration and displays the message that the replication operation has completed successfully.

Enter password: Processing... Backing up server SRV06 Backup complete. Iiscnfg / save

Save the IIS configuration database and schema to disk.

Grammar

Iiscnfg [.vbs] / save [/ s Computer [/ u [Domain] User [/ p Password]

Parameters.

/ s Computer

Copies the IIS configuration database on the specified remote computer to the target computer. This parameter runs the script on the remote computer. Type the remote computer name or IP address (without a backslash). The default value is the local computer.

/ u [Domain] User

Run the script with the privileges of a specific user account. The default value is the current user on the local computer. If the current user is not an administrator of the remote computer, you must use this parameter.

/ p Password

Specifies the password for the user account specified in the / u parameter. If you omit this parameter, IISCnfg prompts you for a password and hides the text you typed.

/?

Displays help at the command prompt.

Annotation

■ to perform this process, you must be a member of the local computer Administrators group, or you must be delegated the appropriate permissions. If you join a computer to a domain, members of the Domain Admins group may also be able to perform this process. As the best practice for security, you can consider using the mode of operation to perform this process.

Any changes that ■ makes to the configuration database using scripts or IIS managers are first written to memory and then to disk when the next scheduled update, which may occur in a few minutes, occurs. This allows the administrator to make changes to the configuration database and then just open metabase.xml to see if the changes are not reflected. The / save command in iiscnfg.vbs solves this problem by saving changes to disk immediately.

Example

The following example shows how to use iiscnfg / save in a specific situation.

Save the IIS configuration of the local computer

The following command saves the IIS configuration to disk on your local computer.

Iiscnfg / save

In response, Iiscnfg.vbs displays the following success message.

Backup complete. Save the IIS configuration of the remote computer

The following command saves the IIS configuration to disk on your local computer.

Iiscnfg / save / s SourceServer / u Administrator / p Kj30W

In response, iiscnfg.vbs displays the following message.

Configuration saved comment

■ IISCnfg.vbs imports and exports all or part of the configuration information stored by IIS in the configuration database of the IIS server. The / copy operation copies the entire configuration database and schema of the IIS server to the target computer. The / save operation copies the entire configuration database and schema of the IIS server to the disk of the target computer.

■ Iisback.vbs, the IIS backup management script, also saves and restores the IIS configuration. However, Iisback.vbs backs up the entire configuration database and schema. You cannot use it to save or restore the selected elements of the configuration.

The ■ IISCnfg copy operation (/ copy) replaces the functionality of the IISSync.vbs and IISRepl.vbs tools previously included in Windows.

■ Iiscnfg requirements

The computer on which ■ issued the command must be running the Windows XP or Windows Server 2003 operating system. The user must be a member of the Administrators group on the computer affected by the command.

The computer affected by the ■ command must be running Windows Server 2003 with Internet Information Services (IIS) 6.0 integrated.

The configuration database of the ■ IIS server includes system-specific and computer-specific properties. Do not import the configuration of one IIS server to another IIS server without modification. Instead, use the IISBack.vbs or IISCnfg copy operation (/ copy), which replaces system-specific and computer-specific properties, making the configuration valid on the target computer. For information about importing and exporting IIS configuration databases, search for "configuration Database Import / Export" in the IIS 6.0help. For more information about how to access IIS 6.0help, see viewing Internet Information Services (IIS) 6.0help.

When ■ connects to the IIS service on the specified computer, Iiscfng.vbs displays the Connect to Server message. This message appears every time you use Iiscnfg.vbs, whether on a local or remote computer.

■ Iiscnfg.vbs provides options to include inherited attributes in the exported file. If you select this option, Iiscnfg.vbs adds the inheritance attribute of the export key to the IIsInheritedProperties key in the export file. When you import a key from this file, you can choose to import the inheritance properties of the key.

When you import inherited properties, the import key retains the inherited properties in the export configuration. If no inherited properties are imported, the key inherits the properties of the imported configuration.

■ to prevent unauthorized use of the exported file, IISCnfg.vbs lets you encrypt the exported file with a password. The password encrypts the session key, which in turn encrypts all properties that have security properties set.

You can read the encrypted export file (only the session key and security attributes are encrypted) and delete the file. However, the export file cannot be used in the / import operation unless an encrypted password is provided. In addition, password encryption cannot be removed from the exported file, nor can you change the encrypted password.

If password encryption is not possible, the session key and security properties are encrypted with a blank password, which prevents reading, but allows any member of the Administrators group to import the configuration database from the export file. IIS 5.1 and 6. 0 do not support computer key encryption for exported files.

Thank you for reading, the above is the content of "how to use Iiscnfg.vbs IIS configuration script", after the study of this article, I believe you have a deeper understanding of how to use Iiscnfg.vbs IIS configuration script, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report