![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Creating an IIS7 application with PowerShell I seem to be stuck trying to create a new IIS application using WMI and PowerShell. Based on code generated from WMIExplorer, I created the following function: function make-webapplication ($AppPath, $Directory, $SiteName) { $Computer = "." $Class = "Application" $Method = "Create" $MC = [WmiClass]"\\$Computer\ROOT\WebAdministration:$Class" $InParams = $mc.psbase.GetMethodParameters($Method) $InParams.ApplicationPath = $AppPath $InParams.PhysicalPath = $Directory $InParams.SiteName = $SiteName "Calling Application. : Create with Parameters :" $inparams.PSBase.properties | select name,Value | format-Table $R = $mc.PSBase.InvokeMethod($Method, $inParams, $Null) "Result :" $R | Format-list } However, whenever I run the function I get an error on the InvokeMethod call with a parameter error. |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Creating an IIS7 application with PowerShell Joe Brinkman wrote:
to a function, and wrote the commands line-by-line. I started off with: $AppPath="/newapp" $Directory="C:\test" $SiteName="Default Web Site" $Computer="." So try it without putting everything into a function just to see. Perhaps something is happening to the args once passed in, so make sure to echo them to the screen. (Great VBScript examples: http://www.iis.net/articles/onepagea...n-Pools-on-IIS) Marco -- ---------------- PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: Creating an IIS7 application with PowerShell Marco, I tried it from the command line as well when I first posted and I recieved exactly the same error. I am running on Vista so IIS7 is slightly different. Since the original code was generated by WMIExplorer I assumed that the code is probably correct. I am wondering if there may be some IIS setting or configuration that is not correct. I have tried running as both an admin and non-admin and I get the same error.
| ||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: Creating an IIS7 application with PowerShell Joe Brinkman wrote:
Check this guy's super-duper IIS blog for code samples: http://weblogs.asp.net/steveschofield/default.aspx Marco -- ---------------- PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: Creating an IIS7 application with PowerShell Joe Brinkman wrote:
app was created successfully. I had just added IIS (for this test), and the web scripting component to this VM, so IIS is set to all the defaults. I ran the code against the default web site. Have you tried this on a new site with the default settings? I don't have SP1 installed, do you? Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com | ||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Creating an IIS7 application with PowerShell OK. I am an idiot. I guess sometimes you really should look at the documentation closely. I was passing in a sitename thinking that it described the web application rather than the site where I was adding the application. My original function works just fine. Although on a positive note, I now have a better understanding of using WMI with Powershell (although the WMI part of that eqation still presents plenty of mystery). Thanks for all the help. Joe Brinkman ---------------------------------------------------------- DotNetNuke Corp. ASP.Net MVP www.dotnetnuke.com ----------------------------------------------------------
| ||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem creating Application in IIS 6 | bsbirdwell | PowerShell | 1 | 02-20-2008 03:43 PM |
| Problem creating Application in IIS 6.0 | bsbirdwell | PowerShell | 0 | 02-20-2008 10:20 AM |
| What no IIS7 PowerShell Examples (yet)? | Flowering Weeds | PowerShell | 4 | 01-08-2008 04:55 PM |
| creating a powershell webservice | Justin Rich | PowerShell | 2 | 09-06-2007 10:37 AM |
| Creating WC in PowerShell | Brandon Shell | PowerShell | 3 | 08-16-2006 07:11 AM |