« Previous Next »

Thread: Rename site using WMI

Last post 09-04-2008 2:38 AM by ksingla. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 08-11-2008, 11:53 AM

    Rename site using WMI

    I am really struggling with this. Does anyone know how to rename a site through WMI within IIS 7.0? It looks like I will have to do a Delete and Create but I can't see how to do this and copy all the site settings + applications. You can rename through the front end so this must be possible through WMI?

  • 08-11-2008, 9:44 PM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 863

    Re: Rename site using WMI

    Any reason to stick with WMI solution? Are you open to a non-wmi solution?

    Thanks,
    Kj

    Follow me on twitter at http://twitter.com/kjsingla
  • 08-12-2008, 3:44 AM In reply to

    Re: Rename site using WMI

    I am integrating into an existing installation routine which uses VB script to manage web sites so a WMI solution would be ideal. I'm open to any suggestions though.

     

    Thanks

    Sam

  • 09-03-2008, 8:35 AM In reply to

    • airtom
    • Not Ranked
    • Joined on 07-08-2008, 3:01 PM
    • Posts 8

    Re: Rename site using WMI

    i am in the same situation. but to be honest, don't count on doing everything in clear VBS. i had to give up in some operations, like changing site name or even creating sites! (http://forums.iis.net/t/1150762.aspx). i think microsoft didn't give us a good WMI provider for IIS7...

    you will probably also find out a good way of calling appcmd.exe from VB script...

    i solved it in this way:

    ...
    sSiteName = "old name"
    sSiteNewName = "new name"
    If Not ShellExec("c:\windows\system32\inetsrv\appcmd.exe set site """ & sSiteName & """ /name:""" & sSiteNewName & """" ) = 0 Then
    ...
    ...
    Set oWshShell = CreateObject("WScript.Shell")
    ...
    ' ShellExec
    ' *********************************************************
    Function ShellExec(ByVal sCmd)
        Dim oExec
           
        Set oExec = oWshShell.Exec(sCmd)
        Do While oExec.Status = 0
            WScript.Sleep 100
        Loop
       
        ShellExec = oExec.ExitCode
    End Function
    ....

     

    good luck :-)

  • 09-04-2008, 2:38 AM In reply to

    • ksingla
    • Top 10 Contributor
    • Joined on 06-14-2006, 3:02 AM
    • Redmond, WA
    • Posts 863

    Re: Rename site using WMI

    There is a possibility of having location tags in applicationHost.config which refers to old site names after site rename. You should go through list of location tags and update those as well. I dont know of a way to do that using Appcmd or WMI. You can do this using AhAdmin or MWA.

    Thanks,
    Kanwal

    Follow me on twitter at http://twitter.com/kjsingla
Page 1 of 1 (5 items)
Microsoft Communities