Powershell Core – Update – Linux – CentOS

Background

Recent disclosure from Microsoft shares news of Powershell Core security vulnerabilities.

Let us quickly review whether we need to apply the patch to our Linux/CentOS box.

 

Scope

Please keep in mind that the vulnerability does not affect Windows Powershell, but Powershell Core.

Windows PowerShell runs only on MS Windows.

Powershell Core is multi-OS.

One initiates Powershell Windows via “powershell”.

Whereas PowerShell Core is initiated via pwsh.

 

Powershell Upgrade

Outline

  1. Get Current Version
  2. If Version needs to be patched
    • Apply Patch
    • Validate Patch

Get Current Version

Outline

  1. Powershell – Command
    • Powershell – Command – (Get-Host).Version

Powershell – Command

Powershell – Command – (Get-Host).Version

Syntax

pwsh -Command "(Get-Host).Version"

 

Sample

pwsh -Command "(Get-Host).Version"

Output
Output – Image

Output – Text
>pwsh -Command "(Get-Host).Version"

Major Minor Build Revision
----- ----- ----- --------
7      1      1    -1

>
Explanation
  1. The Version Number is 7.1.1.1

Apply Patch

Outline

  1. yum
    • yum info
    • yum update

yum

yum info

Syntax

yum info powershell

 

Sample

yum info powershell
Output
Output – Image

Output – Text

>yum info powershell
Repository packages-microsoft-com-prod is listed more than once in the configuration
Last metadata expiration check: 0:01:37 ago on Fri 09 Jul 2021 10:31:51 PM PDT.
Installed Packages
Name         : powershell
Version      : 7.1.1
Release      : 1.rhel.7
Architecture : x86_64
Size         : 170 M
Source       : powershell-7.1.1-1.rhel.7.src.rpm
Repository   : @System
From repo    : packages-microsoft-com-prod
Summary      : PowerShell is an automation and configuration management platform.
URL          : https://microsoft.com/powershell
License      : MIT License
Description  : PowerShell is an automation and configuration management platform.
             : It consists of a cross-platform command-line shell and associated scripting language.

Available Packages
Name         : powershell
Version      : 7.1.3
Release      : 1.rhel.7
Architecture : x86_64
Size         : 65 M
Source       : powershell-7.1.3-1.rhel.7.src.rpm
Repository   : packages-microsoft-com-prod
Summary      : PowerShell is an automation and configuration management platform.
URL          : https://microsoft.com/powershell
License      : MIT License
Description  : PowerShell is an automation and configuration management platform.
             : It consists of a cross-platform command-line shell and associated scripting language.

>

Explanation
  1. Installed Package
    • Version:- 7.1.1
    • Size:- 170 M
    • Source:- powershell-7.1.1-1.rhel.7.src.rpm
  2. Available Package
    • Version:- 7.1.3
    • Size:- 65 M
    • Source:- powershell-7.1.3-1.rhel.7.src.rpm

 

yum update

Syntax

yum update <package>

 

Sample

yum update powershell -y
Output
Output – Image

Output – Text


>sudo yum update powershell -y
[sudo] password for dadeniji:
Last metadata expiration check: 2:56:30 ago on Fri 09 Jul 2021 07:42:50 PM PDT.
Dependencies resolved.
=============================================================================================================================================================
 Package                          Architecture                 Version                               Repository                                         Size
=============================================================================================================================================================
Upgrading:
 powershell                       x86_64                       7.1.3-1.rhel.7                        packages-microsoft-com-prod                        65 M

Transaction Summary
=============================================================================================================================================================
Upgrade  1 Package

Total download size: 65 M
Downloading Packages:
powershell-7.1.3-1.rhel.7.x86_64.rpm                                                                                         7.3 MB/s |  65 MB     00:08
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                        7.3 MB/s |  65 MB     00:08
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                     1/1
  Upgrading        : powershell-7.1.3-1.rhel.7.x86_64                                                                                                    1/2
  Running scriptlet: powershell-7.1.3-1.rhel.7.x86_64                                                                                                    1/2
  Cleanup          : powershell-7.1.1-1.rhel.7.x86_64                                                                                                    2/2
  Running scriptlet: powershell-7.1.1-1.rhel.7.x86_64                                                                                                    2/2
  Verifying        : powershell-7.1.3-1.rhel.7.x86_64                                                                                                    1/2
  Verifying        : powershell-7.1.1-1.rhel.7.x86_64                                                                                                    2/2
Installed products updated.

Upgraded:
  powershell-7.1.3-1.rhel.7.x86_64

Complete!
>


Explanation
  1. Downloaded Package
  2. Installed Package

Validate Patch

Outline

  1. Powershell – Command
    • Powershell – Command – (Get-Host).Version
  2. Powershell Application
    • pwsh – Application – pwsh -v

Powershell – Command

Powershell – Command – (Get-Host).Version

Syntax

pwsh -Command "(Get-Host).Version"

 

Sample

pwsh -Command "(Get-Host).Version"

Output
Output – Image

Output – Text
&gt;pwsh -Command "(Get-Host).Version"

Major Minor Build Revision
----- ----- ----- --------
7      1      3    -1

Explanation
  1. The Version Number is 7.1.3.-1

 

Powershell – Application

Powershell – Application – pwsh -v

Outline

To initiate Powershell core, please issue pwsh.

To get the version number, please pass along the -v argument.

 

Syntax

pwsh -v

 

Sample

pwsh -v

Output
Output – Image

Output – Text

pwsh -v
PowerShell 7.1.3

Explanation
  1. The Version Number is 7.1.3

 

References

  1. Microsoft
    • Microsoft Azure
      • Update PowerShell versions 7.0 and 7.1 to protect against a remote code execution vulnerability
        Link

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s