Use IIS 7 extension from script invoked in custom hostRSS

1 reply

Last post Nov 12, 2008 11:19 PM by spencer205

  • Use IIS 7 extension from script invoked in custom host

    Nov 11, 2008 05:16 PM|spencer205|LINK

    Hi All,

    I've written a WCF service that hosts PowerShell in it.  When certain sys-admin-ie operations on the service are invoked, it calls a PowerShell script via this custom host.  This is done, so that sys admins can modify the PowerShell script without the Web service needing to be recompiled or redeployed.

    One of the sys-admin-ie things that the service needs to do is create some Web sites in IIS.  To this end, I was looking to use the IIS 7 PowerShell Provider.  However, using this tool requires that a special console file be invoked in order to make the extensions available.  Is there a way to do the same things that the PSC1 file is doing in C# on my custom host in the Web service, so that the cmdlets (e.g., New-WebSite) are available from within the script?

    TIA!

    --

    Regards,


    Travis Spencer
     

  • Re: Use IIS 7 extension from script invoked in custom host

    Nov 12, 2008 11:19 PM|spencer205|LINK

    Got it.It seems that running this from the script invoked by the service will do the trick:

    add-pssnapin IIsProviderSnapIn

    See http://forums.iis.net/p/1148874/1867336.aspx for more info.