IIS/VBScript – GetObject – Error – 2147221020

Background

Stole some code and now I can’t get it to work.

Error

Error Image

error.2147221020.20190207.0152PM

Error Text

>cscript getWebService.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

Enumerating websites on localhost

GetObject IIS://localhost/W3SVC
Error Number :- -2147221020
Error Source :-
Error Description :-

Code


OPTION EXPLICIT

ON ERROR RESUME Next

DIM CRLF, TAB
DIM strServer
DIM objWebService
Dim strPathName

TAB  = CHR( 9 )
CRLF = CHR( 13 ) & CHR( 10 )

IF WScript.Arguments.Length = 1 THEN
    strServer = WScript.Arguments( 0 )
ELSE
    strServer = "localhost"
END IF

WScript.Echo "Enumerating websites on " & strServer & CRLF

strPathName =  "IIS://" & strServer & "/W3SVC" 

WScript.Echo "GetObject " & strPathName

Err.Clear

rem SET objWebService = GetObject( "IIS://" & strServer & "/W3SVC" )

SET objWebService = GetObject( strPathName  )

If ( Err.Number  0 ) Then 

	Wscript.Echo "Error Number :- " + CSTR(Err.Number)

	Wscript.Echo "Error Source :- " + Err.Source

	Wscript.Echo "Error Description :- " + Err.Description

END IF

Remediation

 

Outline

  1. Please enable IIS 6 Metabase
    • Access Control Panel
    • Access Programs and Features
      • Within Programs and Features, choose Windows
    • Add Roles and Features Wizard
      • Web Server ( IIS )
        • Management Tools
          • IIS 6 Management Compatibility

 

ScreenShot

Add Roles and Features Wizard

Add Roles and Features Wizard – Server Roles

Add Roles and Features Wizard – Server Roles – Web Server

Management Tools – IIS 6 Management Compatibility – Adding Role – Management Service

iis.addRoles.after.20190207.0110PM.PNG

Management Tools – IIS 6 Management Compatibility – Confirm Installation Selections

iis.confirm.20190207.0110PM.PNG

Management Tools – IIS 6 Management Compatibility – Installation Progress

iis.installationCompleted.20190207.0115PM.PNG

Management Tools – IIS 6 Management Compatibility – Installation Completed

iis.installationCompleted.20190207.0115PM.PNG

Credit

David Wang

Link

David.Wang.20190207.0159PM

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s