Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
711 views
in Technique[技术] by (71.8m points)

iis 7 - Powershell New-WebApplication

[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")

New-WebApplication -Name 'testApp' -Site 'Default Web Site' -PhysicalPath c:est -ApplicationPool DefaultAppPool 

That is the contents of test.ps1. When I run .est.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:codeworkusersmchevettest.ps1:6 char:19 + New-WebApplication <<<< -Name 'testApp' -Site 'Default Web Site' -PhysicalPath c:est -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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:WindowsSysWoW64WindowsPowerShellv1.0powershell.exe

To use the 64-bit version (on a 64-bit OS), call this one from your program:

C:WindowsSystem32WindowsPowerShellv1.0powershell.exe

Using C:WindowsSysNativeWindowsPowerShellv1.0powershell.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...