« Previous Next »

Thread: Powershell, ADSI and IIS 6 (on Win2003)

Last post 05-27-2008 10:47 AM by thompsonson. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 05-22-2008, 1:24 PM

    Powershell, ADSI and IIS 6 (on Win2003)

    I am trying to script the change of ScriptMaps variable on some IIS Websites (IIS 6 on Win2003). I have been using ADSI to get the value but I cannot find a way to Set (Put) the value.

     ([ADSI]"IIS://$computer/$name").Properties["ScriptMaps"]

    So i tried this:

    PS > $scriptmaps = ([ADSI]"IIS://$computer/$name").Properties["ScriptMaps"]
    PS > $scriptmaps = $scriptmaps + ".css,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG"
    PS > ([ADSI]"IIS://$computer/$name").Put("ScriptMaps", $scriptmaps)

    But it does not work, the new value for .css has not been added. Any ideas?

     Thanks,

    Matt 

     

  • 05-27-2008, 5:03 AM In reply to

    Re: Powershell, ADSI and IIS 6 (on Win2003)

     After you .Put("here", "something"), you should apply changes by calling .SetInfo() method.

     Also, make a variable from ([ADSI]"IIS://$computer/$name") in the first place, like:

    PS > $mySite = [ADSI]"IIS://$computer/$name"
    PS > $scriptmaps = $mySite.Properties["ScriptMaps"]
    PS > $scriptmaps = $scriptmaps + ".css,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,5,GET,HEAD,POST,DEBUG"
    PS > $mySite.Put("ScriptMaps", $scriptmaps)
    PS > $mySite.SetInfo()
  • 05-27-2008, 10:47 AM In reply to

    Re: Powershell, ADSI and IIS 6 (on Win2003)

    Thats brilliant cheers13. I have seen some odd behaviour though - ended up using this for the get:

    $scriptmaps = $mySite.psbase.Properties.ScriptMaps

     

    for a time the Put was erroring (complaining about the arguments given) and I used this:  

    $mySite.psbase.Properties.ScriptMaps = $scriptmaps

    though this started to complain so I reverted and Put was working... no idea at the mo what is going on but it's working! Matt 

     

Page 1 of 1 (3 items)
Microsoft Communities