1. | Open the \My Documents\Microsoft Press\VBScriptSBS\Templates\Blank Template.vbs script in Microsoft Notepad or some other script editor and save it as YourNameBackUpIISMetaBase.vbs.
|
2. | As the first non-commented line, type Option Explicit.
|
3. | Declare the following variables: strPassword, strFilePath, strMetabasePath, intFlags, locatorObj, providerObj, and computerObj. Your completed Header information section will look like the following:
Option Explicit
Dim strPassword
Dim strFilePath
Dim strMetabasePath
Dim intFlags
Dim locatorObj
Dim providerObj
Dim computerObj
|
4. | Define three constants to be used to control the export behavior: EXPORT_CHILDREN = 0, EXPORT_INHERITED = 1, and EXPORT_NODE_ONLY = 2. The EXPORT_CHILDREN constant is used to add the properties of child keys to the export file. The EXPORT_INHERITED constant is used to add inherited properties to the exported keys, and the EXPORT_NODE_ONLY constant does not add subkeys of the specified key to the export file. The constants section of the script will look like the following:
Const EXPORT_CHILDREN = 0
Const EXPORT_INHERITED = 1
Const EXPORT_NODE_ONLY = 2
|
5. | Assign the password "ExportingPassw0rd" to the strPassword variable.
|
6. | Specify the physical path for the exported metabase. To do this, assign the value of "C:\exported.xml" to the strFilePath variable.
|
7. | Set strMetabasePath to be equal to "/lm/logging/custom logging". This is seen in the Metabase.xml file.
|
8. | Set the intFlags variable equal to EXPORT_NODE_ONLY OR EXPORT_INHERITED constants. This will tell the export command to show only the node with inherited properties. This section of the script looks like the following:
strPassword = "ExportingPassw0rd"
strFilePath = "C:\exported.xml"
strMetabasePath = "/lm/logging/custom logging"
intFlags = EXPORT_NODE_ONLY OR EXPORT_INHERITED
|
9. | Set the locatorObj variable equal to the object that comes back to the SWbemLocator object when you use the CreateObject command. This code looks like the following:
Set locatorObj = CreateObject("WbemScripting.SwbemLocator")
|
10. | Set the providerObj variable equal to the object that comes back from using the ConnectServer method of SWbemLocator. At this point, the object will be used to connect into the London server MicrosoftIISv2 namespace. This line of code looks like the following:
Set providerObj = locatorObj.ConnectServer _
("London", "root/MicrosoftIISv2")
|
11. | Set the computerObj variable equal to the object into IIsComputer = 'LM' when you use the Get method of the providerObj object. This line of code looks like the following:
Set computerObj = providerObj.Get("IIsComputer = 'LM'")
|
12. | Call the Export method from the computer object. The command needs the values that are contained in the strPassword, strFilePath, strMetabasePath, and intFlags variables. The code looks like the following:
computerObj.Export strPassword, strFilePath, strMetabasePath, intFlags
|
13. | Print out the results by using the WScript.Echo command to echo out a message that includes the values contained in the variables strMetabasePath and strFilePath. Your code could look like the following:
WScript.Echo "Exported the node at " & strMetabasePath _
& " to " & strFilePath
|
14. | Save and run the script. If it does not perform as expected, compare your script with \My Documents\Microsoft Press\VBScriptSBS\ch19\StepByStep\BackUpIIS MetaBase.vbs.
|