PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and the associated scripting language. For Windows users working with PyKotor, certain scripts and utilities may require PowerShell. This guide will help you set up PowerShell on your system and address common issues related to script execution policies.
PowerShell comes pre-installed on most modern versions of Windows. However, if you need to install or update PowerShell, follow these steps:
- Visit the official PowerShell GitHub page.
- Download the latest release suitable for your Windows version.
- Run the installer and follow the on-screen instructions.
-
Open a terminal window.
-
Run the following command to install PowerShell:
sudo apt-get install -y powershell
sudo dnf install -y powershell
brew install --cask powershell
or
brew install pwsh
-
Once installed, you can launch PowerShell by typing
pwsh
in your terminal.
If you are struggling to get Powershell setup on your system, and you're using linux/mac, try running our automated installer instead:
./install_powershell.sh
To run PowerShell scripts (.ps1
files), you might need to change the execution policy. By default, PowerShell restricts the execution of scripts to prevent unauthorized scripts from running on your system.
-
Open PowerShell as an administrator.
-
Run the following command to allow script execution:
Set-ExecutionPolicy Unrestricted
-
Choose
Y
when prompted to change the execution policy.
This command allows our scripts to run on your system. If you do not have admin privileges, see the next section.
If you encounter an error stating that a script is not digitally signed, you can bypass this error temporarily by running the script with the following command:
PowerShell.exe -ExecutionPolicy Bypass -File path\to\your\script.ps1
Replace path\to\your\script.ps1
with the actual path to the script you want to run.
When working with the PyKotor source files directly from GitHub, you may need to run PowerShell scripts for setting up the development environment. For instance, install_python_venv.ps1
is a PowerShell script that automates the creation of a Python virtual environment and sets up necessary environment variables for PyKotor development.
- Clone the PyKotor repository and navigate to the project directory.
- Run the following command(s):
./install_python_venv.ps1
pwsh
./install_python_venv.ps1
This script checks for the appropriate Python version, installs it if necessary, and sets up a virtual environment for PyKotor development.
This guide provided an overview of how to install PowerShell on different operating systems, how to configure your system to run PowerShell scripts, and how to use PowerShell for setting up the PyKotor development environment. For more detailed information, refer to the official PowerShell documentation.