Summary
A Script Task from a deployment or build plan may fail with the following error:
PowerShell is not recognized as an internal or external command, operable program or batch file
Environment
Bamboo (or its agents) running on Windows OS.
Diagnosis
If your Bamboo version is 6.10.2 or older, please beware of the following bug:
However, if you're running a more recent version of Bamboo, or you also experience this issue when running the PowerShell command directly from Windows' Command Prompt, please proceed with the below.
Cause
This is caused by the user (or system) PATH environment variable not containing the directory where the PowerShell executable resides. It's usually located at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe, and although the PATH variable contains the C:\Windows\System32 directory, Windows may have trouble locating the executable within its subfolders.
Solution
The solution consists of adding the directory where the PowerShell executable resides to the PATH environment variable.
- Search for "environment variables" in the Windows search bar and open the respective Control Panel item.
- A System Properties window will appear. Click on "Environment Variables" at the bottom.
- Edit the PATH environment variable and add the path to the folder where PowerShell is
located.
- For the changes to be picked up, the agent needs to be restarted. You may also need to restart the machine so all of the other Windows portions pick up the new variable.
You can install version 1 of the AWS Command Line Interface (AWS CLI) on Windows by using a standalone installer (recommended) or pip, which is a package manager for Python.
Don't include the prompt symbol (C:\>) when you type a command. These are included in program listings to differentiate commands that you type from output returned by the AWS CLI. The rest of this guide uses the generic prompt symbol ($), except in cases where a command is Windows-specific.
Topics
- Install, update, and uninstall the AWS CLI version 1 using the MSI installer
- Install, update, and uninstall the AWS CLI version 1 using Python and pip on Windows
- Add the AWS CLI version 1 executable to your command line path
- Troubleshooting AWS CLI install and uninstall errors
Install, update, and uninstall the AWS CLI version 1 using the MSI installer
The AWS CLI version 1 is supported on Windows XP or later. For Windows users, the MSI installation package offers a familiar and convenient way to install the AWS CLI version 1 without installing any other prerequisites.
Install and update the AWS CLI version 1 using the MSI installer
Check the Releases page on GitHub to see when the latest version was released. When updates are released, you must repeat the installation process to get the latest version of the AWS CLI version 1.
Download the appropriate MSI installer:
AWS CLI MSI installer for Windows (64-bit): //s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi
AWS CLI MSI installer for Windows (32-bit): //s3.amazonaws.com/aws-cli/AWSCLI32PY3.msi
AWS CLI combined setup file for Windows: //s3.amazonaws.com/aws-cli/AWSCLISetup.exe (includes both the 32-bit and 64-bit MSI installers, and automatically installs the correct version)
Run the downloaded MSI installer or the setup file.
Follow the on-screen instructions. By default, the AWS CLI version 1 installs to C:\Program Files\Amazon\AWSCLI (64-bit version) or C:\Program Files (x86)\Amazon\AWSCLI (32-bit version).
To confirm the installation, use the aws --version command at a command prompt (open the Start menu and search for cmd to start a command prompt).
C:\> aws --version aws-cli/1.22.23 Python/3.8.8 Windows/10 botocore/1.13If Windows is unable to find the program, you might need to close and reopen the command prompt to refresh the path, or add the installation directory to your PATH environment variable manually.
Uninstall the AWS CLI version 1
To use the following uninstall instructions, you need to have installed the AWS CLI version 1 with the MSI installer or setup file.
Open Programs and Features by doing one of the following:
Open the Control Panel, and then choose Programs and Features.
Open a command prompt and enter the following command.
C:\> appwiz.cpl
Select the entry named AWS Command Line Interface, and then choose Uninstall to launch the uninstaller.
Confirm that you want to uninstall the AWS CLI.
(Optional) Remove the shared AWS SDK and AWS CLI settings information in the .aws folder.
These configuration and credentials settings are shared across all AWS SDKs and the AWS CLI. If you remove this folder, they cannot be accessed by any AWS SDKs that are still on your system.
The default location of the .aws folder differs between platforms, by default the folder is located in %UserProfile%\.aws.
Install, update, and uninstall the AWS CLI version 1 using Python and pip on Windows
The Python Software Foundation provides installers for Windows that include pip.
Prerequisites
You must have Python 3.6 or later installed. For installation instructions, see the Downloading Python page in Python's Beginner Guide.
Python 2.7 was deprecated by the Python Software Foundation on January 1, 2020. Starting with AWS CLI version 1.20.0, a minimum version of Python 3.6 is required.
In order to use the AWS CLI version 1 with an older version of Python, you need to install an earlier version of the AWS CLI version 1. To view the AWS CLI version 1 Python version support matrix, see Python version requirements.
Install and update the AWS CLI version 1 using pip
To Install the AWS CLI version 1, use the pip3 command (if you use Python version 3 or later) or the pip command.
For the latest version of the AWS CLI, use the following command block:
C:\> pip3 install awscli --upgrade --userFor a specific version of the AWS CLI, append a less-than symbol < and the version number to the filename. For this example the filename for version 1.16.312 would be <1.16.312 resulting in the following command:
C:\> pip3 install awscli<1.16.312 --upgrade --userVerify that the AWS CLI version 1 is installed correctly. If there is no response, see the Add the AWS CLI version 1 executable to your command line path section.
C:\> aws --version aws-cli/1.22.23 Python/3.8.8 Windows/10 botocore/1.13
Uninstall the AWS CLI version 1 using pip
If you installed the AWS CLI version 1 using pip, you must also uninstall using pip. If you use Python version 3 or later, we recommend that you use the pip3 command.
C:\> pip3 uninstall awscliYou might need to restart your command prompt window or your computer to remove all files.
(Optional) Remove the shared AWS SDK and AWS CLI settings information in the .aws folder.
These configuration and credentials settings are shared across all AWS SDKs and the AWS CLI. If you remove this folder, they cannot be accessed by any AWS SDKs that are still on your system.
The default location of the .aws folder differs between platforms, by default the folder is located in %UserProfile%\.aws.
$ rmdir %UserProfile%\.aws
Add the AWS CLI version 1 executable to your command line path
After installing the AWS CLI version 1 with pip, add the aws program to your operating system's PATH environment variable. With an MSI installation, this should happen automatically. But if the aws command doesn't run after you install it, you might need to set it manually.
Use the where command to find the aws file location. By default, the where command shows where a specified program is found in the system's PATH.
C:\> where awsThe paths that show up depend on your platform and which method you used to install the AWS CLI. Folder names that include version numbers can vary. These examples reflect the use of Python version 3.7. Replace the version with the version number you're using, as needed. Typical paths include the following:
Python 3 and pip3 – C:\Program Files\Python37\Scripts\
Python 3 and pip3 --user option on earlier versions of Windows – %USERPROFILE%\AppData\Local\Programs\Python\Python37\Scripts
Python 3 and pip3 --user option on Windows 10 – %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts
MSI installer (64-bit) – C:\Program Files\Amazon\AWSCLI\bin
MSI installer (32-bit) – C:\Program Files (x86)\Amazon\AWSCLI\bin
Use the following steps based on whether a file path is returned.
Press the Windows key and enter environment variables.
Choose Edit environment variables for your account.
-
Choose PATH, and then choose Edit.
Add the path you found into the Variable value field, for example, C:\Program Files\Amazon\AWSCLI\bin\aws.exe.
Choose OK twice to apply the new settings.
Close any running command prompts and reopen the command prompt window.
Troubleshooting AWS CLI install and uninstall errors
If you come across issues after installing or uninstalling the AWS CLI, see Troubleshooting AWS CLI errors for troubleshooting steps. For the most relevant troubleshooting steps, see Command not found errors, The "aws --version" command returns a different version than you installed, and The "aws --version" command returns a version after uninstalling the AWS CLI.