Powershell New-WebApplication [英] Powershell New-WebApplication
问题描述
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
New-WebApplication -Name 'testApp' -Site 'Default Web Site' -PhysicalPath c:\test -ApplicationPool DefaultAppPool
这是测试的内容的.ps1。
当我运行.\test.ps1时出现以下错误。
That is the contents of test.ps1. When I run .\test.ps1 I get the following error.
New-WebApplication:无法检索动态参数对于
cmdlet。检索具有CLSID
{688EEEE5-6A7E-422F-B2E1-6AF00DC944A6}的组件的COM类工厂由于以下
错误而失败:80040154.在C:\ code\work \ users \ mchevett\test.ps1:6 char:19
+ New-WebApplication<<<< -Name'testApp'-Site'默认网站'
-PhysicalPath c:\ test -ApplicationPool DefaultAppPo ol
+ CategoryInfo:InvalidArgument:(:)
[New-WebApplication],ParameterBindingException
+ FullyQualifiedErrorId:
GetDynamicParametersException,Microsoft.IIs.PowerShell.Provider.NewWebApplicationCommand
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!
推荐答案
我遇到了完全相同的问题,因为我从我的程序中调用了错误版本的PowerShell。我不确定这一点,但我认为当你有一个x86程序时,它会调用PowerShell的x86版本,但失败了。
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.
要专门使用 32位版本,请从您的程序中调用此项:
To specifically use the 32-bit version, call this one from your program:
C:\Windows\SysWoW64\WindowsPowerShell\v1.0\powershell.exe
要使用 64位版本(在64位操作系统上),请从您的程序中调用此版本:
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
使用 C:\ Windows \SysNative\WindowsPowerShell\v1.0\powershell.exe
从32位进程内将为您提供64位PowerShell。在64位进程中使用它会给你一个文件未找到的错误。
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.
这篇关于Powershell New-WebApplication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!