« Previous Next »

Thread: New Binding (WMI VbScript)

Last post 04-11-2009 5:46 AM by RustySpoon. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 04-03-2009, 12:21 PM

    • RustySpoon
    • Top 500 Contributor
    • Joined on 12-14-2008, 10:41 AM
    • Sopron - Hungary
    • Posts 14

    New Binding (WMI VbScript)

    Hy Guys! I have some probleme with this script.I try to add a new binding (subdomain) to a site. oSite.Bindings property is an array, but I can't extend it with my new binding object (oBindingNew). I get this error in the line b(lb+1)=oBindingNew: Object doesnt support this property or method.
    domain="try.com"
    subdomain="hy"
    
    'WebAdmin obj
    Set oIIS = GetObject("winmgmts:root\WebAdministration") 
    
    Set oBindingNew = oIIS.Get("BindingElement").SpawnInstance_            
    oBindingNew.BindingInformation = "*:80:" & subdomain & "." & domain            
    oBindingNew.Protocol = "http"   
    
    Set oSite = oIIS.Get("Site.Name='" & domain & "'")
    
    Dim lb
    lb=UBound(oSite.Bindings) 
    Dim b()
    ReDim Preserve b(lb+1)
    b(lb+1)=oBindingNew 
    oSite.Bindings= b
    
    'oSite.put_
    
  • 04-10-2009, 9:26 AM In reply to

    Re: New Binding (WMI VbScript)

    Hi,

    Actually, you do not need to add the new BindingElement to the bindingsCollection.
    I did some changes base on you script. It add a new BindingElement successfully without delete those BindingElement exists.

    domain="try.com"
    subdomain="hy"

    'WebAdmin obj
    Set oIIS = GetObject("winmgmts:root\WebAdministration")

    Set oBindingNew = oIIS.Get("BindingElement").SpawnInstance_           
    oBindingNew.BindingInformation = "*:80:" & subdomain & "." & domain           
    oBindingNew.Protocol = "http"  

    Set oSite = oIIS.Get("Site.Name='" & domain & "'")

    oSite.Bindings= array(oBindingNew)
    oSite.put_

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 04-11-2009, 5:46 AM In reply to

    • RustySpoon
    • Top 500 Contributor
    • Joined on 12-14-2008, 10:41 AM
    • Sopron - Hungary
    • Posts 14

    Re: New Binding (WMI VbScript)

    Thank you! It works!
Page 1 of 1 (3 items)
Microsoft Communities