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

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

那就是test.ps1的内容。
当我运行。\ test.ps1时,出现以下错误。



此错误消息根本无法帮助我。任何想法如何获得更好的错误消息?谢谢阅读!

最佳答案

我遇到了完全相同的问题,因为我从程序中调用了错误版本的PowerShell。我对此不太确定,但是我认为当您使用x86程序时,它将调用x86版本的PowerShell,但会失败。

要专门使用 32位版本,请从您的程序中调用此代码:

C:\Windows\SysWoW64\WindowsPowerShell\v1.0\powershell.exe

要使用 64位版本(在64位操作系统上),请从您的程序中调用此版本:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

在32位进程中使用C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exe将为您提供64位powershell。在64位进程中使用它会给您一个找不到文件的错误。

关于iis-7 - Powershell新Web应用程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6866150/

10-12 13:03
查看更多