Iiscnfg.vbs IIS Configuration Scripts _vbs

Source: Internet
Author: User
Tags comments configuration settings ftp site administrator password metabase

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 (metabase and schema) to another computer to replicate the configuration. IIsCnfg performs the following functions:

To view the command syntax, click the following command:

Iiscnfg/export

Copies all or part of the IIS metabase to an XML file in an encrypted or unencrypted format. You can then use an XML file in the import operation to copy all or part of the metabase to another IIS configuration.

Grammar
Iiscnfg[.vbs]/export/f [Path]filename.xml/sp metabasepath [/D Encryptingpassword] [/inherited] [/children] [s/s Compute R [/u [domain]user [/P Password]]]

Parameters
/F [Path]filename.xml
Necessary. Specifies the unique name and location of the exported file. If you specify an existing file or if the directory in the specified path does not exist, this command will fail.
The file path must be a local path. 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 using the specified password. You can use any string as your password.
The/d parameter creates a secure export file by encrypting the session key and security properties 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 export file is encrypted with a blank password. This allows only security attributes to be encrypted, and any administrator can use the export file to import the metabase configuration.

/inherited
Adds an inherited property of the exported key to the export file. Without this parameter, the export file does not include attributes inherited from a higher level key.
/children
Adds the child key of the specified key recursively to the export file.
/s Computer
Runs the script on the specified remote computer. Type the computer name or IP address (without backslashes). By default, scripts are run on the local computer.
/u [domain]user
Run the script with the permissions of the specific user account. This 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 this argument is omitted, the script prompts you to enter a password and hides the text you typed.
/?
Displays help at the command prompt.
Comments
To perform this procedure, 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 procedure. As a security best practice, consider using the Run method to perform this procedure.
Use quotation marks to enclose metabase path elements that contain spaces. Enclose only elements with spaces, excluding the entire path. For example, you should type the default FTP Site/iisadmin instead of the default FTP Site/iisadmin.
Example
The following example shows how to use Iiscnfg/export in a particular case.
Export Web Site Configuration
The following command exports the configuration of the Finance Web site to the C:financefinance.xml file. This command uses the/SP parameter to specify the configuration database path/LM/W3SVC/2 for the Web site, and uses the/children parameter to export all of the configured child keys. It also uses the/inherited parameter to include inherited properties in the exported file. This ensures 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 resulting file will include all keys and subkeys within the/LM/W3SVC/2 path. It also includes a iisinheritedproperties key that contains the values of all inherited properties.

Export the entire IIS configuration for the local computer
The following command exports the IIS configuration of the local computer to the D:iistestconfig.xml file. It uses the/F parameter to specify the filename and location, using the/SP parameter to specify the root key (/) of the metabase. The/children parameter adds all the subkey keys of the root key recursively to the export file. (If there is no/children parameter, only the root key is exported.) Finally, the command uses the/d parameter and password to encrypt the exported file.

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 the configuration is also different from the system's MetaBase.xml file, even if it is fully exported. session keys, access control lists (ACLs), and passwords are different.

In addition, it is not possible to determine whether or not to encrypt by simply viewing the export file. However, if you compare the encrypted version and the unencrypted version of the same file, you will find that the value of the security attribute in the encrypted version has changed. Therefore, if there is no password, the file will not be available for the import command.

Iiscnfg/import

Adds the configuration settings of the XML metabase export file to the IIS server's configuration database.

Grammar
Iiscnfg[.vbs]/import/f [path]filename/sp sourcepath/dp DestinationPath [/D Encryptingpassword] [/children] [/inherite D] [/merge] [/s Computer [/u [domain]user [/P Password]]]

Parameters
/F [Path]filename
Necessary. Specifies the path and file name of the XML source file.
The file path must be a local path. 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 that is being imported in the XML file. When the key appears in an XML file, enter its metabase path. To import all the keys in the source file, enter the metabase path to the root key.
/DP DestinationPath
Necessary. Specifies the location where the import key is placed in the configuration database. Enter the configuration database path.
If the specified path already exists in the metabase, the import key overrides and replaces the key currently in the metabase path without warning.

/d Encryptingpassword
Specifies the password used to encrypt the configuration data.
This parameter is required to encrypt the configuration file. This command fails if the password for the encrypted file is not provided, or if an incorrect password is provided.

/children
Recursively imports the child key of the specified key.
/inherited
The inherited property of the import key. This parameter is valid only if the source file includes inherited properties.
/merge
Merges the key in the XML file with the existing metabase key. Without this parameter, the key in the XML file replaces the existing key in the same metabase path.
The/merge parameter adds the key that appears only in the XML file to the configuration database, retains the key that is not in the XML file in the metabase, and applies the values in the XML file when the key appears in both the XML file and the metabase.

/s Computer
runs the script on the specified remote computer. Type the computer name or IP address (without backslashes). By default, scripts are run on the local computer.
/u [domain]user
runs the script with the permissions of a specific user account. This 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 this argument is omitted, the script prompts you to enter a password and hides the text you typed.
/? The
displays help at a command prompt.
Note
To perform this procedure, 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 procedure. As a security best practice, consider using the Run method to perform this procedure. The
uses quotation marks to enclose metabase path elements that contain spaces. Enclose only elements with spaces, excluding the entire path. For example, you should type the default FTP Site/iisadmin instead of the default FTP Site/iisadmin. The
imported key must be the expected type in the new location in the metabase path. If the key is a non-expected type, the configuration will not function correctly. For example, do not import event logging configuration (/lm/logging) to a Web site configuration path, such as/LM/W3SVC/3. The
changes made using Iiscnfg.vbs can take effect immediately. When a file is updated (every 5 seconds or every 50 times), these changes are reflected in the MetaBase.xml file.
Example
The following example shows how to use Iiscnfg/import in a particular case.
Import Web site from export file
The following command imports the NewSite Web site configuration from the C:config.xml file to the configuration database.

The 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 import in the Config.xml file. At this point, the NewSite configuration will be located in the/LM/W3SVC/5 path of the Config.xml file. It then uses the/DP (target path) parameter to specify the configuration database location where the import key should be placed. At this point, you should import the NewSite configuration key into the/LM/W3SVC/3 location in the configuration database. Finally, it will use the/children parameter in the import operation to contain the/LM/W3SVC/5 of the child key. If there is no/children parameter, only the site root directory is imported.

Remember that there is no warning when the/import operation is overwritten. If the metabase already has a key in the/LM/W3SVC/3 location, the keys will be replaced by the import key.

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 you use this command, the NewSite configuration appears in IIS in the third web site, and its metabase path is/LM/W3SVC/3.

To import a logging configuration to a remote computer
The following procedure imports the custom logging configuration from C:iislogging.xml into the IIS metabase of the remote computer. You can propagate the configuration to a group of servers using this method or an extension of the method.

The steps to import a logging configuration into a remote computer are two-step:

1. Copy the source files to the remote computer. (Iiscnfg.vbs does not allow a remote path in the/F parameter.) )
2. Import the configuration to 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 Svr126 IIS configuration. It uses the/F parameter to identify the source file, uses the/SP parameter to specify the/lm/logging/custom Logging metabase path to import, and uses the/DP parameter to place the import key in the same location as the target configuration/lm/logging/custom 。 (use quotation marks to enclose a path element that contains spaces.) It uses the/children parameter to import all of the child keys of the log record key.

In order to operate on Svr126, it uses the/s parameter to specify the remote computer, using the/U and/P parameters to run a script that has permissions on the user's administrator account 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 server ... has been completed. Configuration imported From/lm/logging/custom logging in file C:iislogging.xml to/lm/logging/custom logging in the Meta Base. [Drink a little wine net]http://blog.const.net.cn/a/615.htm results, the/lm/logging/custom Logging key and its child keys are copied from the local configuration database to the Svr126 configuration database.

Merging a virtual directory with a Web site
This example illustrates the workings of the/merge parameter by comparing the standard import operation with the import operation using the/merge parameter.

All two commands use the same import file Invest_vdir.xml to update the properties of the investments virtual directory for the Web site.

The following example shows the investments configuration database key before any import operation is run. (This example is obtained from a backup copy of the metabase that was created using iisback.vbs).

Configuration database prior to import

<iiswebvirtualdir Location = "/lm/w3svc/1509060625/root/investments" accessflags= "AccessRead |  AccessScript "appfriendlyname=" Investments "appisolated=" 2 "approot="/lm/w3svc/1509060625/root/investments " dirbrowseflags= "DirBrowseShowDate | Dirbrowseshowtime | Dirbrowseshowsize | dirbrowseshowextension | Dirbrowseshowlongdate | EnableDefaultDoc "Path=" E:publicdownload > </IIsWebVirtualDir> The following example shows the Invest_vdir.xml that will be used in the import operation The contents of the file. (This example is created by exporting the investments metabase key and then editing the export file.) )

Note 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 property.
The DirBrowseFlags property is omitted.
Import file Contents

<iiswebvirtualdir Location = "/lm/w3svc/1509060625/root/investments" accessflags= "AccessRead" AuthFlags= " authanonymous | AUTHNTLM "appfriendlyname=" Investments "appisolated=" 2 "approot="/lm/w3svc/1509060625/root/investments "Path=" E:pu Blicdownload "> </IIsWebVirtualDir> 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 investments key in the XML file.

The command uses the/F parameter to specify the import file and uses the same metabase path in the source path (/SP) and the target path (/DP) parameter.

iiscnfg/import/f e:iistestinvest_vdir.xml/sp/lm/w3svc/1509060625/root/investments/dp/lm/w3svc/1509060625/root/ Investments

After you use this command, the investments key in the metabase 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 key in the Invest_vdir.xml file into the configuration database. The/merge parameter instructs IIS to add new properties from the import file to the metabase, to keep metabase properties that are not in the import file unchanged, and to apply the import file value when the property appears in both the import file and the metabase.

This command is the same as command 1, except that the/merge parameter is added.

iiscnfg/import/f e:iistestinvest_vdir.xml/sp/lm/w3svc/1509060625/root/investments/dp/lm/w3svc/1509060625/root/ Investments/merge

When this command is used, the contents of the investments key in the metabase are a combination of its sources, as shown in the following example.

Please note that the following properties of the investments key in the metabase have changed:

The value of the AccessFlags property that is displayed in the metabase and XML file has changed. The values in the XML file now appear in the configuration database.
Added AuthFlags property that is displayed only in an XML file.
The DirBrowseFlags property that is displayed only in the configuration database has not changed.
<iiswebvirtualdir Location = "/lm/w3svc/1509060625/root/investments" accessflags= "AccessRead" AppFriendlyName= " Investments "appisolated=" 2 "approot="/lm/w3svc/1509060625/root/investments "authflags=" AuthAnonymous | AUTHNTLM "dirbrowseflags=" DirBrowseShowDate | Dirbrowseshowtime | Dirbrowseshowsize | dirbrowseshowextension | Dirbrowseshowlongdate | EnableDefaultDoc "path=" E:publicdownload "> </IIsWebVirtualDir> iiscnfg/copy

Copy the IIS metabase and schema from one computer to another computer.

Grammar
Iiscnfg[.vbs]/copy/ts targetcomputer/tu targetuser/tp Targetpassword [/s Computer [/u [domain]user [/P Password]]]

Parameter
/ts targetcomputer
Required. Copies the IIS configuration database to the specified computer. Type the IP address or computer name (without backslashes).
/tu Targetuser
is required. Specifies the account used to connect to the target computer. Type the user account in the [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 an administrator on the target computer.

/TP Targetpassword
is required. 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 destination computer. This parameter will run the script on the remote computer. Type the remote computer name or IP address (without backslashes). The default value is the local computer.
/u [domain]user
runs the script with the permissions of a specific user account. The default value is the current user on the local computer. You must use this parameter if the current user is not an administrator on the remote computer.
/P Password
Specifies the password for the user account specified in the/u parameter. If this argument is omitted, IIsCnfg prompts you to enter a password and hides the text you typed.
/? The
displays help at a command prompt.
Note
To perform this procedure, 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 procedure. As a security best practice, consider using the Run method to perform this procedure.
By default, iiscnfg copies the configuration database for the local computer to the target computer specified by the/ts parameter. However, you can use the/s parameter to copy the configuration database of another computer to the destination computer. The
copy operation uses iisback.vbs to create a backup copy of the source configuration database and schema. It then copies the backup copy file (. MDX and. SCX) to the target computer and replaces the configuration database and schema of the target computer with the iisback.vbs by using the backup copy. Although these operations can be done manually, the IISCNFG copy operation provides a convenient step-by-step way to replicate the IIS configuration.
This replication operation does not replicate server content related to IIS configuration, such as Web pages and FTP files. The
replication operation changes computer-specific and system-specific properties in the metabase so that they are valid on the target computer. However, it does not adjust the directory or file path. The path in this configuration may not be valid on the target computer. The following example of
example
shows how to use iiscnfg/copy in a particular case.

Copy the IIS configuration for 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 uses the/TU and TP parameters to provide the administrator account and password for the user 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. IP address 127.0.0.1 is a loopback address and is generally referred to as the local computer. This address is used only when replicating the configuration of the local computer.

To replicate the IIS configuration of a remote computer
The following command copies the SRV06 IIS configuration of the remote computer to the MAINBKP server. This command uses the/s command to identify the remote computer and uses the/U parameter to provide the administrator password for the user on the SRV06 computer. It also uses the/ts parameter to identify the target server, using the/TU and TP parameters to provide the administrator account and password for the user on the MAINBKP server.

Unlike the optional/p parameter, the/TP parameter is required. If this argument is omitted, this 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 the typed password character.) Then, after confirming the password, it copies the configuration and displays the message that the copy operation 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 destination computer. This parameter will run the script on the remote computer. Type the remote computer name or IP address (without backslashes). The default value is the local computer.
/u [domain]user
Run the script with the permissions of the specific user account. The default value is the current user on the local computer. You must use this parameter if the current user is not an administrator on the remote computer.
/P Password
Specifies the password for the user account specified in the/u parameter. If this argument is omitted, IIsCnfg prompts you to enter a password and hides the text you typed.
/?
Displays help at the command prompt.
Comments
To perform this procedure, 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 procedure. As a security best practice, consider using the Run method to perform this procedure.
Any changes made to the metabase using either the script or IIS Manager will be written to memory first, and then written to disk at the next scheduled update, which may occur several minutes later. This allows the administrator to make changes to the metabase and then open MetaBase.xml only to see if the changes have not been reflected. The/save command in iiscnfg.vbs resolves the issue by saving changes to disk immediately.
Example
The following example shows how to use iiscnfg/save in a particular situation.

Save the IIS configuration for the local computer
The following command saves the IIS configuration to a disk on the local computer.

Iiscnfg/save

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

Backup complete. To save the IIS configuration of a remote computer
The following command saves the IIS configuration to a disk on the local computer.

iiscnfg/save/s sourceserver/u administrator/p kj30w

In response, Iiscnfg.vbs displays the following message.

Configuration saved annotation

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 destination computer. The/save operation copies the entire configuration database and schema of the IIS server to the disk of the destination computer.
Iisback.vbs is the IIS backup management script and also saves and restores the IIS configuration. However, Iisback.vbs will back up the entire configuration database and schema. It cannot be used to save or restore a selected element of a configuration.
The iiscnfg copy operation (/COPY) replaces the functionality of the Iissync.vbs and Iisrepl.vbs tools that were previously included in Windows.
IIsCnfg Requirements
The computer that issued the command must be running Windows XP or the Windows Server 2003 operating system. The user must be a member of the Administrators group on the computer to which the command affects.
The computer that the command affects must be running Windows Server 2003, which integrates Internet information Services (IIS) 6.0.
The configuration database for 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, using the iisback.vbs or iiscnfg copy operation (/copy), this replaces system-specific and computer-specific properties, making the configuration valid on the target computer. For information about importing and exporting the IIS metabase, search for "Metabase import/Export" in IIS 6.0 Help. For more information about how to access IIS 6.0 help, see Viewing Internet Information Services (IIS) 6.0 Help.
When you connect 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, either locally or on a remote computer.
Iiscnfg.vbs will provide the option to include inherited properties in the exported file. If you select this option, Iiscnfg.vbs adds the inherited property of the exported key to the Iisinheritedproperties key in the export file. When you import a key from this file, you can choose to import the inherited property of the key.
When you import an inherited property, the import key retains the inherited properties from the export configuration. If you do not import an inherited property, the key inherits the properties of the imported configuration.

To prevent unauthorized use of the exported file, Iiscnfg.vbs allows you to encrypt the exported file with a password. The password encrypts the session key, which in turn encrypts all properties that have the security properties set.
You can read the encrypted export file (only the session key and security attributes are encrypted), and you can delete the file. However, you cannot use the export file in the/import operation unless you provide an encrypted password. In addition, password encryption cannot be removed from the exported file, and the encrypted password cannot be changed.

If password encryption is not available, 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 metabase from the export file. Both IIS 5.1 and 6.0 do not support computer key encryption for export files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.