Add ServerBinding to IIS web site using Wscript

I have now spent 5 hours trying to add extra ServerBindings to an existing IIS web site (Win2K Server, multiple sites, no Active Directory) using script. I can add the first one no problem, but when I try to add more I get all kinds of problems. After much searching I have discovered that I probably need to use the ADSI method PutEx, but it refuses to allow me to append - I can only update (which replaces all existing bindings). ADS_PROPERTY_APPEND and ADS_PROPERTY_DELETE are not listed in IISHELP but are detailed on MSDN. Does anybody know why or how to get round it?

const ADS_PROPERTY_CLEAR = 1
const ADS_PROPERTY_UPDATE = 2
const ADS_PROPERTY_APPEND = 3
const ADS_PROPERTY_DELETE = 4

Set NewWebServer = GetObject("IIS://ServerName/w3svc/1")
NewBindingsArray = Array(0)
NewBindingsArray(0) = ":80:www.domain.com"
NewWebServer.PutEx ADS_PROPERTY_APPEND, "ServerBindings", NewBindingsArray
NewWebServer.SetInfo
madlejAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CharlyozCommented:
Try this: (It's a bit basic, but the functionality works.)

Dim IISOBJGlobal, LogLocation, GlobalDefDoc, GlobalScriptMaps
Dim IISOBJSiteCode, SiteCode, HostHeaders, SecureBind, ServerComm, SiteDefDoc
Dim IISOBJSiteRoot, SiteRoot
 
'Get WMI Object
Set IISOBJGlobal = GetObject("IIS://LocalHost/w3svc")
Set IISOBJSiteCode = GetObject("IIS://LocalHost/w3svc/1")
Set IISOBJSiteRoot = GetObject("IIS://LocalHost/w3svc/1/Root")
 
'Global
'Set Global Default Logging Location
LogLocation = "D:\Logfiles"
 
'Set Global Default Document
GlobalDefDoc = ""
 
'Set Global Script Mappings
GlobalScriptMaps=Array(".asp,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".cer,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".cdx,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE",".asa,C:\WINNT\System32\inetsrv\asp.dll,1,GET,HEAD,POST,TRACE")
 

'Set Server Comment Field
ServerComm = "SiteName Description"
 
'Set host header array
HostHeaders = Array("123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com","123.123.123.123:80:url.mydomain.com")

'Set Secure Bindings array
SecureBind = Array("123.123.123.123:443:","123.123.123.123:443:","123.123.123.123:443:")
 
'Set Default Document for website
SiteDefDoc = ""
 
'Set Site Root Path
SiteRoot = "D:\Inetpub\wwwroot"
 
'Add all SiteCode entries to Metabase
'Global
IISOBJGlobal.LogFileDirectory=LogLocation
IISOBJGlobal.DefaultDoc=GlobalDefDoc
IISOBJGlobal.ScriptMaps=GlobalScriptMaps
IISOBJGlobal.SetInfo
'Site Specific
IISOBJSiteCode.ServerComment=ServerComm
IISOBJSiteCode.ServerBindings=HostHeaders
IISOBJSiteCode.SecureBindings=SecureBind
IISOBJSiteCode.DefaultDoc=SiteDefDoc
IISOBJSiteCode.SetInfo
'Site Root specific
IISOBJSiteRoot.Path=SiteRoot
IISOBJSiteRoot.SetInfo
0
CharlyozCommented:
BTW. the text:

HostHeaders = Array("123.123.123.123:80:url.mydomain.

should all be on one line.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
madlejAuthor Commented:
Sorry, my error. I was using the following line to make the bindings array:

   NewBindingsArray = Array(0)

This works fine for a one element array, however:

   NewBindingsArray = Array(2)

does not make an array with 3 elements. I just looked straight through this obvious error for hours. So in the end I didn't need to use PutEx, but simply:

   NewWebServer.ServerBindings = NewBindingsArray

Still don't know why PutEx append doesn't work though!
0
madlejAuthor Commented:
PS. thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.