Thread: WMI and IIS 7
View Single Post
Old 01-06-2008   #3 (permalink)
RichS


 
 

Re: WMI and IIS 7

Theres no *must* about it

I've already posted to my blog about using V2 remoting and the .NET
Microsoft.Web.Administration namespace. Using appcmd via PowerShell remoting
seems a backward step.

I wanted to investigate the WMI provider for IIS 7 to see if it was any
easier or gave any advantages - current conclusion is the .NET method is
easier to understand and get working
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Marco Shaw [MVP]" wrote:
Quote:

> RichS wrote:
Quote:

> > I have been investigating using PowerShell to administer IIS 7. Using the
> > Microsoft.Web.Administration namespace I have sucessfully created and deleted
> > sites, applications and applicationpools - see recent posts on my blog for
> > details.
> >
> > This code also works very nicely through the remoting features of PowerShell
> > V2. Hurrah we're 2 for 2
> >
> > Now comes the problem - IIS 7 also exposes a WMI provider
> >
> > I have managed to do a certain amount through WMI and PowerShell
> >
> > $site = Get-WmiObject -Namespace "root\webadministration" -Class Site
> > -Filter "Name = 'WTest1'"
> >
> > $site | Set-WmiInstance -Argument @{ServerAutoStart = "False"}
> >
> > $site.Stop()
> > $site.Start()
> >
> > $site.psbase.Delete()
> >
> > Such as changing properties of the site stoppping & starting & deleting
> > sites. The one point where I have hit a wall is creating a site using WMI.
> > I have found a reference to doing it with VBScript
> >
> > http://www.iis.net/articles/view.asp...s-WMI-Provider
> >
> > but I cannot duplicate this in PowerShell. I am open to suggestions (within
> > resaon ;-) ) and would be extremely grateful if someone can point out what I
> > am missing
> >
>
> Any particular reason you *must* do this with WMI? Using the v2
> remoting, you could just use appcmd.exe.
>
> I am trying it out though. No luck so far either here, but I've thought
> of a few things since last night, but I've not time to try them until
> tomorrow evening or so.
>
> --
> Microsoft MVP - Windows PowerShell
> http://www.microsoft.com/mvp
>
> PowerGadgets MVP
> http://www.powergadgets.com/mvp
>
> Blog:
> http://marcoshaw.blogspot.com
>
My System SpecsSystem Spec