简体   繁体   English

AWS CodeDeploy Powershell 脚本无法在 IIS 服务器中创建网站和池

[英]AWS CodeDeploy Powershell Script fail to create website & Pool in IIS server

I have an app that I am deploying using AWS Codedeploy to an EC2 instance running Windows Server 2012 R2 with code deploy agent installed.我有一个应用程序,我正在使用 AWS Codedeploy 将其部署到运行 Windows Server 2012 R2 且安装了代码部署代理的 EC2 实例。

The code revision was successfully downloaded from S3 bucket to EC2 instance but PowerShell script throws error.代码修订已成功从 S3 存储桶下载到 EC2 实例,但 PowerShell 脚本引发错误。

Just to inform, when executing the script in EC2 instance manually it is running successfully.只是通知一下,在 EC2 实例中手动执行脚本时,它运行成功。

Here are the my appspec.yml & before-install.bat这是我的 appspec.yml 和 before-install.bat

  • appspec.yml appspec.yml

    version: 0.0 os: windows files: - source: \\index.html destination: C:\\DemoApp\\MySite hooks: BeforeInstall: - location: \\before-install.bat timeout: 900

  • before-install.bat安装前.bat

    C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Command "& {Import-Module WebAdministration; New-Item iis:\\Sites\\MySite -bindings @{protocol=\\"http\\";bindingInformation=\\":80:\\"} -physicalPath c:\\DemoApp\\MySite; New-Item IIS:\\AppPools\\MyPool; Set-ItemProperty IIS:\\Sites\\MySite -name applicationPool -value MyPool;}"

codedeploy-agent-deployments.log codedeploy-agent-deployments.log

Script - \\before-install.bat C:\\Windows\\system32>C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Command "& {Set-ExecutionPolicy Unrestricted; Import-Module WebAdministration; New-Item iis:\\Sites\\MySite -bindings @{protocol=\\"http\\";bindingInformation=\\":80:\\"} -physicalPath c:\\DemoApp\\MySite; New-Item IIS:\\AppPools\\MyPool; Set-ItemProperty IIS:\\Sites\\MySite -name applicationPool -value MyPool;}" New-Item : Cannot retrieve the dynamic parameters for the cmdlet.脚本 - \\before-install.bat C:\\Windows\\system32>C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -Command "& {Set-ExecutionPolicy Unrestricted; Import-Module WebAdministration; New-Item iis :\\Sites\\MySite -bindings @{protocol=\\"http\\";bindingInformation=\\":80:\\"} -physicalPath c:\\DemoApp\\MySite; New-Item IIS:\\AppPools\\MyPool; Set-ItemProperty IIS :\\Sites\\MySite -name applicationPool -value MyPool;}" 新项目:无法检索 cmdlet 的动态参数。 Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).由于以下错误,检索具有 CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} 的组件的 COM 类工厂失败:80040154 类未注册(来自 HRESULT 的异常:0x80040154 (REGDB_E_CLASSNOTREG)。 At line:1 char:71 + & {Set-ExecutionPolicy Unrestricted;在 line:1 char:71 + & {Set-ExecutionPolicy Unrestricted; Import-Module WebAdministration;导入模块 Web 管理; New-Item i ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : InvalidArgument: (:) [New-Item], ParameterBindin gException + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShe ll.Commands.NewItemCommand新项目我 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : InvalidArgument: (:) [New-Item ], ParameterBinding gException +fullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.NewItemCommand

Try this script:试试这个脚本:

if ($PSHOME -like "*SysWOW64*")
{
  Write-Warning "Restarting this script under 64-bit Windows PowerShell."

  & (Join-Path ($PSHOME -replace "SysWOW64", "SysNative") powershell.exe) -File `
    (Join-Path $PSScriptRoot $MyInvocation.MyCommand) @args

  Exit $LastExitCode
}

Import-Module WebAdministration; 
New-Item IIS:\AppPools\MyPool;
New-Item iis:\Sites\MySite -bindings @{protocol='http';bindingInformation=':80:'} -physicalPath c:\DemoApp\MySite;
Set-ItemProperty IIS:\Sites\MySite -name applicationPool -value MyPool

Refer to http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html .请参阅http://docs.aws.amazon.com/codedeploy/latest/userguide/troubleshooting-deployments.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM