How to Install PowerShell on AlmaLinux 8
If you’re tired of juggling Bash one‑liners that barely get the job done, this guide will show you how to get Microsoft’s cross‑platform PowerShell up and running on AlmaLinux 8. By the end you’ll have a fully functional pwsh shell that can talk to Azure, run Windows‑style scripts, or just give you tab‑completion that actually works.
What you need before you start
- A fresh AlmaLinux 8 system with root or sudo access.
- An internet connection (the packages are pulled from Microsoft’s repo).
- Optional: a bit of patience if the first attempt throws “package not found” – it usually means the repository wasn’t added correctly.
Add the Microsoft package repository
PowerShell isn’t in the default AlmaLinux repos, so we have to tell dnf where to look.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
This imports Microsoft’s signing key; without it dnf will refuse to trust any packages from the new repo.
Next create the repo file:
cat <<EOF | sudo tee /etc/yum.repos.d/microsoft.repo
[microsoft]
name=Microsoft Packages
baseurl=https://packages.microsoft.com/rpm/almalinux/8/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
The tee command writes the block to a file that dnf reads. If you skip this step you’ll get a “No package PowerShell available” error, which I’ve seen happen more often than it should.
Install PowerShell
Now we can pull in the actual package:
sudo dnf install -y powershell
The -y flag auto‑confirms the installation; otherwise you’ll be stuck answering “yes/no?” for every dependency. The installer resolves a handful of runtime libraries, so let it finish.
Verify the installation
Run the shell with:
pwsh
If everything went smoothly you should see the PowerShell prompt:
PowerShell 7.x.x-alma8-x64
PS /home/youruser>
Type Get-Host to confirm the version. If the command isn’t found, double‑check that /usr/bin/pwsh exists and that your $PATH includes /usr/local/bin.
Optional: Make PowerShell your default shell
Some people like to replace Bash entirely. You can do it with:
chsh -s $(which pwsh) $USER
After you log out and back in, the prompt will be the familiar PS> instead of $. If you ever need Bash again just run bash from within PowerShell.
Common pitfalls
- Missing repository – Double‑check the URL in /etc/yum.repos.d/microsoft.repo. A typo will cause a 404 and leave dnf clueless.
- GPG key errors – If you see “key is not installed”, re‑run the rpm --import line; sometimes network hiccups corrupt the download.
- SELinux denials – On a locked‑down system SELinux may block the binary. Use setenforce 0 temporarily to test, then create a proper policy if needed.
That’s it. You now have PowerShell on AlmaLinux 8 and can start scripting with the same cmdlets you’d use on Windows. Have fun automating, and feel free to drop a comment if something went sideways.