AWS CodeDeploy Powershell Script Cannot Create Website and Pool on IIS Server

I have an application that I am deploying using AWS Codedeploy to an EC2 instance running Windows Server 2012 R2 with the Code Deployment agent installed.

The code version was successfully loaded from the S3 bucket into the EC2 instance, but the PowerShell script throws an error.

Just report that when you execute the script on an EC2 instance, it runs successfully.

Here are my appspec.yml and before-install.bat

  • 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

    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

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 IIS Item: \ AppPools \ MyPool; Set-ItemProperty IIS: \ Sites \ MySite -name applicationPool -value MyPool;} "New Item: Unable to get dynamic parameters for cmdlet. Getting the COM class factory for the 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)). On the line: 1 char: 71 + and {Set-ExecutionPolicy Unrestricted; Import-module WebAdministration;New item ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo: InvalidArgument: (:) [New-Item], ParameterBindin gException + FullyQualifiedErrorId: GetDynamicParametersException, Microsoft.PowerShe ll.Commands.NewItemCommand

+3


source to share


1 answer


Try this script:

if ($ PSHOME-like "SysWOW64") {Write-Warning "Reload 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 IIS item: \ AppPools \ MyPool; New iis item: \ 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 .

+3


source







All Articles