

# Install the CodeDeploy agent for Windows Server
<a name="codedeploy-agent-operations-install-windows"></a>

On Windows Server instances, you can use one of these methods to download and install the CodeDeploy agent:
+ Use Amazon Systems Manager (recommended)
+ Run a series of Windows PowerShell commands.
+ Choose a direct download link.
+ Run an Amazon S3 copy command.

**Note**  
The folder that the CodeDeploy agent is installed to is `C:\Program Data\Amazon\CodeDeploy`. Make sure there are no directory junctions or symlinks on this path.

**Topics**
+ [Use Systems Manager](#codedeploy-agent-operations-install-system-manager)
+ [Use Windows PowerShell](#codedeploy-agent-operations-install-windows-powershell)
+ [Use a direct link](#codedeploy-agent-operations-install-windows-direct-link)
+ [Use an Amazon S3 copy command](#codedeploy-agent-operations-install-windows-s3-copy)

## Use Systems Manager
<a name="codedeploy-agent-operations-install-system-manager"></a>

Follow the instructions in [Install the CodeDeploy agent using Amazon Systems Manager](codedeploy-agent-operations-install-ssm.md) to install the CodeDeploy agent.

## Use Windows PowerShell
<a name="codedeploy-agent-operations-install-windows-powershell"></a>

Sign in to the instance, and run the following commands in Windows PowerShell:

1.  Require that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher. If you are prompted to change the execution policy, type "**Y**." 

   ```
    Set-ExecutionPolicy RemoteSigned
   ```

1.  Load the Amazon Tools for Windows PowerShell. 

   ```
   Import-Module AWSPowerShell
   ```

1.  Create a directory into where the CodeDeploy agent installation file is downloaded. 

   ```
   New-Item -Path "c:\temp" -ItemType "directory" -Force
   ```

1. Configure Amazon credentials using the `Set-AWSCredential` and `Initialize-AWSDefaultConfiguration` commands. For more information, see [Using Amazon credentials](https://docs.amazonaws.cn/powershell/latest/userguide/specifying-your-aws-credentials.html) in the *Amazon tools for PowerShell User Guide*.

1.  Download the CodeDeploy agent installation file. 
**Note**  
Amazon supports the latest minor version of the CodeDeploy agent. Currently the latest minor version is 1.7.x.

   **For the China (Beijing) Region**:

   To install the latest version of the CodeDeploy agent:
   + 

     ```
     powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-cn-north-1 -Key latest/codedeploy-agent.msi -File c:\temp\codedeploy-agent.msi
     ```

   To install a specific version of the CodeDeploy agent:
   + 

     ```
     powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-cn-north-1 -Key releases/codedeploy-agent-###.msi -File c:\temp\codedeploy-agent.msi
     ```

   **For the China (Ningxia) Region**:

   To install the latest version of the CodeDeploy agent:
   + 

     ```
     powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-cn-northwest-1 -Key latest/codedeploy-agent.msi -File c:\temp\codedeploy-agent.msi
     ```

   To install a specific version of the CodeDeploy agent:
   + 

     ```
     powershell.exe -Command Read-S3Object -BucketName aws-codedeploy-cn-northwest-1 -Key releases/codedeploy-agent-###.msi -File c:\temp\codedeploy-agent.msi
     ```

1.  Run the CodeDeploy agent installation file. 

   ```
   c:\temp\codedeploy-agent.msi /quiet /l c:\temp\host-agent-install-log.txt
   ```

To check that the service is running, run the following command:

```
powershell.exe -Command Get-Service -Name codedeployagent
```

 If the CodeDeploy agent was just installed and has not been started, then after running the **Get-Service** command, under **Status**, you should see **Start...**:

```
Status     Name                DisplayName
------     ----                -----------
Start...   codedeployagent    CodeDeploy Host Agent Service
```

If the CodeDeploy agent is already running, after running the **Get-Service** command, under **Status**, you should see **Running**:

```
Status     Name                DisplayName
------     ----                -----------
Running    codedeployagent    CodeDeploy Host Agent Service
```

## Use a direct link
<a name="codedeploy-agent-operations-install-windows-direct-link"></a>

If the browser security settings on the Windows Server instance provide the permissions (for example, to `http://*.amazonaws.com.cn`), you can use a direct link to download the CodeDeploy agent and then run the installer manually.

For the China (Beijing) Region:

```
[https://aws-codedeploy-cn-north-1.s3.cn-north-1.amazonaws.com.cn/latest/codedeploy-agent.msi](https://aws-codedeploy-cn-north-1.s3.cn-north-1.amazonaws.com.cn/latest/codedeploy-agent.msi)
```

For the China (Ningxia) Region:

```
[https://aws-codedeploy-cn-northwest-1.s3.cn-northwest-1.amazonaws.com.cn/latest/codedeploy-agent.msi](https://aws-codedeploy-cn-northwest-1.s3.cn-northwest-1.amazonaws.com.cn/latest/codedeploy-agent.msi)
```

## Use an Amazon S3 copy command
<a name="codedeploy-agent-operations-install-windows-s3-copy"></a>

If the Amazon CLI is installed on the instance, you can use the Amazon S3 [cp](https://docs.amazonaws.cn/cli/latest/reference/s3/cp.html) command to download the CodeDeploy agent and then run the installer manually. For information, see [Install the Amazon Command Line Interface on Microsoft Windows](https://docs.amazonaws.cn/cli/latest/userguide/awscli-install-windows.html). 

For the China (Beijing) Region, use:

```
aws s3 cp s3://aws-codedeploy-cn-north-1/latest/codedeploy-agent.msi codedeploy-agent.msi --region cn-north-1
```

For the China (Ningxia) Region, use:

```
aws s3 cp s3://aws-codedeploy-cn-northwest-1/latest/codedeploy-agent.msi codedeploy-agent.msi --region cn-northwest-1
```