Installing PowerShell in Kali Linux
After ploughing through the internet and found the the following Microsoft Docs - Installing PowerShell Core on Linux documentation for Kali, I discovered the documented steps may have been obselete and requires updating since there are a few people commenting the installation for Kali just does not work with an issue #2901 raised in PowerShell/PowerShell-Docs public repository in GitHub.
Original steps from documentation below:
1
2
3
4
5
6
7
8
9
10
# Download & Install prerequisites
sudo apt-get install libunwind8 libicu55
wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_amd64.deb
sudo dpkg -i libssl1.0.0_1.0.1t-1+deb8u6_amd64.deb
# Install PowerShell
sudo dpkg -i powershell_6.1.0-1.ubuntu.16.04_amd64.deb
# Start PowerShell
pwsh
Many may have been led astray on how to install PowerShell in Kali with the steps above and I am going to attempt to correct it today until next version is out.
Installing PowerShell in Kali
In this section, I will walkthrough on an up to date steps on how you can install PowerShell in Kali from the time when this blog post is published.
↑Top
Download & Install PowerShell dependencies
Firstly, you will have to install the Libicu57
(International Components for
Unicode) package in order to install PowerShell to Kali Linux because
PowerShell 6.1 has a dependency with that package that contains a library for
Unicode support to interpret a whole heaps of stuffs.
To understand more about International Components for Unicode, you can read about it here.
1
2
3
4
5
6
# Download Libicu57 (International Components for Unicode)
# package from Debian source
wget http://ftp.us.debian.org/debian/pool/main/i/icu/libicu57_57.1-9_amd64.deb
# Use Debian package manager to install Libicu57 package
dpkg -i libicu57_57.1-9_amd64.deb
↑Top
Download & Install prerequisites
Next, you need to install the other supporting packages for setting up Advanced Package Tool (APT) in order to add external public package repository and ensuring you can obtain the package.
1
2
3
4
5
6
7
8
9
10
# Get Advanced Package Tool (APT) to update available
# package list
apt-get update
# Use Advanced Package Tool (APT) to install the following
# packages:
# - curl
# - gnupg
# - apt-transport-https
apt-get install -y curl gnupg apt-transport-https
↑Top
Add Microsoft public repository key to APT as trusted repository
Once the required prerequisites are met, you need to add the Microsoft public repository key to Advanced Package Tool (APT) to configure the repository as a trusted source.
1
2
# Use curl to get the key and add the key to APT
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
↑Top
Add Microsoft package repository to the source list
With the Microsoft public repository key added to Advanced Package Tool (APT), you will have to add the Microsoft public package repository configuration to the source list so that APT will know how to connect to it using the key to obtain a list of available packages.
1
2
3
# Write the package repository source to a powershell
# source list file
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" | tee /etc/apt/sources.list.d/powershell.list
↑Top
Install the PowerShell package
Since you have added a new package repository to the source list, you will have
to use apt-get update
to retrieve a list of available packages from that new
package repository to be available for installation.
Once the Advanced Package Tool (APT) has updated the available package list,
you can use apt-get install
to install the PowerShell package.
1
2
3
4
5
6
# Get Advanced Package Tool (APT) to update available
# package list
apt-get update
# Use Advanced Package Tool (APT) to install PowerShell
apt-get install -y powershell
↑Top
Switch into PowerShell
After the PowerShell package installation has completed, you can use pwsh
to
switch to PowerShell from Bash.
1
2
# Start PowerShell
pwsh
↑Top
Uninstalling PowerShell
To remove PowerShell from Kali Linux, you can use apt-get remove
to uninstall
the PowerShell package from Bash.
1
2
# Uninstall PowerShell package
apt-get remove -y powershell
↑Top
Conclusion
There you have it on how you can obtain PowerShell in Kali.
While you have read this blog post, I have updated the documentation for Microsoft and submitted a pull request #2973 to ensure everyone that are googling out there can get the same method on installing PowerShell in Kali.
Until the pull request has been approved to merge, you can follow the steps in this blog post.
If you find that this information useful, feel free to bookmark this or share it with your colleagues and friends.
↑Top
References
↑Top
Related Books
↑Top