[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") New-WebApplication -Name 'testApp' -Site 'Default Web Site' -PhysicalPath c:\test -ApplicationPool DefaultAppPool
That is the contents of test.ps1. When I run .\test.ps1 I get the following error.
New-WebApplication : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for compon ent with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154. At C:\code\work\users\mchevett\test.ps1:6 char:19 + New-WebApplication <<<< -Name 'testApp' -Site 'Default Web Site' -PhysicalPath c:\test -ApplicationPool DefaultAppPo ol + CategoryInfo : InvalidArgument: (:) [New-WebApplication], ParameterBindingException + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.IIs.PowerShell.Provider.NewWebApplicationCommand
This error message is not helping me at all. Any ideas how to get a better error message? Thanks for reading!
The New-WebApplication cmdlet creates an Internet Information Services (IIS) web application.
The IIS PowerShell namespace consists of items like Web-Sites, Apps, Virtual Directories and Application Pools. Creating new namespace items and managing them is very easy using the built-in PowerShell cmdlets.
I had the exact same problem because I was calling the wrong version of PowerShell from my program. I'm not sure about this but I think when you have a x86 program it calls the x86 version of PowerShell, which fails.
To specifically use the 32-bit version, call this one from your program:
C:\Windows\SysWoW64\WindowsPowerShell\v1.0\powershell.exe
To use the 64-bit version (on a 64-bit OS), call this one from your program:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Using C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe
from within a 32bit process will give you the 64bit powershell. Using it from within a 64bit process will give you a file-not-found error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With