Install Powershell on CentOS 7 – Tutorial

This is a quick post covering how to install Powershell on a Centos 7 machine. You can read more about Powershell Core here. To install on Centos, first enable the repo required by running (in superuser mode):

# sudo su
# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
# exit

Once done, install Powershell by running:

sudo yum install -y powershell

And that’s it! You can run Powershell by typing ‘pwsh’:

[root@centos ~]# pwsh
PowerShell v6.1.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root>

You’re now set up to run Powershell on Linux. Check out the cmdlets included by running ‘gcm’/get-command:

PS /root> gcm

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Add-NodeKeys                                       0.0        PSDesiredStateConfiguration
Function        AddDscResourceProperty                             0.0        PSDesiredStateConfiguration
Function        AddDscResourcePropertyFromMetadata                 0.0        PSDesiredStateConfiguration
Function        cd..
Function        cd\
Function        CheckResourceFound                                 0.0        PSDesiredStateConfiguration
Function        Clear-Host
Function        Compress-Archive                                   1.1.0.0    Microsoft.PowerShell.Archive
Function        Configuration                                      0.0        PSDesiredStateConfiguration
Function        ConvertTo-MOFInstance                              0.0        PSDesiredStateConfiguration
Function        Expand-Archive                                     1.1.0.0    Microsoft.PowerShell.Archive
Function        Find-Command                                       1.6.0      PowerShellGet
Function        Find-DscResource                                   1.6.0      PowerShellGet
Function        Find-Module                                        1.6.0      PowerShellGet
Function        Find-RoleCapability                                1.6.0      PowerShellGet
Function        Find-Script                                        1.6.0      PowerShellGet
Function        Generate-VersionInfo                               0.0        PSDesiredStateConfiguration

Running a get-module command reveals the following:

And that’s it – You have learnt how to install powershell on centos. You can also install PowerCLI on Centos.

Related posts

Mastering the Linux ifconfig Command

Docker Exec Command With Practical Examples

Debugging with Git Bisect

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More