Previous Next

Thread: Microsoft.Web.Administration.ServerManager

Last post 04-25-2008 11:44 AM by sergeia. 5 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (6 items)

Sort Posts:

  • 04-22-2008, 11:30 AM

    • Kanien
    • Top 75 Contributor
    • Joined on 01-31-2008, 12:14 AM
    • Posts 39
    • Kanien

    Microsoft.Web.Administration.ServerManager

    I've looked all over and I can't find any example on how to delete a site in IIS using the Microsoft.Web.Administration.ServerManager.  Any suggestions on where to look for some guidance?

     

  • 04-22-2008, 11:57 AM In reply to

    • thomad
    • Top 10 Contributor
    • Joined on 08-20-2002, 3:28 PM
    • Redmond
    • Posts 387
    • thomad

    Re: Microsoft.Web.Administration.ServerManager

    ServerManager sm = new ServerManager();

    sm.Sites.Remove(sm.Sites["DemoSite"]);

    sm.CommitChanges();

    Hope this helps

    Thomas Deml
    Senior Program Manager
    Internet Information Services
    Microsoft Corp.
  • 04-22-2008, 3:33 PM In reply to

    • marcoshaw
    • Top 500 Contributor
    • Joined on 04-16-2008, 12:47 PM
    • Posts 8
    • marcoshaw

    Re: Microsoft.Web.Administration.ServerManager

    Note: This is C# syntax in a PowerShell sub-forum... ;-)

    I'll try to find time to confirm the exact syntax in PowerShell (once I fire up an IIS7 VM), unless someone else beats me to it. 

  • 04-23-2008, 1:29 PM In reply to

    • sergeia
    • Top 150 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 17
    • sergeia

    Re: Microsoft.Web.Administration.ServerManager

    I don't advise to use Microsoft.Web.Administration classes returned from the provider, we could drop this dependence in future. If you want to use this namespace in Powershell, you have to program it without dependency on provider.

    [System.Reflection.Assembly]::LoadFrom("C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll")
    $sm = new-object Microsoft.Web.Administration.ServerManager
    $sm.Sites["test2"].Delete()
    $sm.CommitChanges()

     

  • 04-23-2008, 1:56 PM In reply to

    • Kanien
    • Top 75 Contributor
    • Joined on 01-31-2008, 12:14 AM
    • Posts 39
    • Kanien

    Re: Microsoft.Web.Administration.ServerManager

    Thanks for the assistance sergeia.

     I was using this to provision accounts, however this was before the IIS provider for PS came out.  Are you saying that I should not use this class?

  • 04-25-2008, 11:44 AM In reply to

    • sergeia
    • Top 150 Contributor
    • Joined on 04-14-2008, 8:47 PM
    • Posts 17
    • sergeia

    Re: Microsoft.Web.Administration.ServerManager

    No, you could use it any way you want. But don't rely on objects, returned from IIS provider always being types from Microsoft.Web.Administration. I wasn't clear enough about it in my previous remark. Currently, if you run get-item "iis:\sites\default web site" | gm, you will see, that returned object is Microsoft.Web.Administration.ConfigurationElement and theoretically you could use it in the script that expects this type.

    But in the future those objects will not be from Microsoft.Web.Administration.

     

    --Sergei

Page 1 of 1 (6 items)
Page view counter