• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install PowerShell on CentOS 7

{{postValue.id}}

How to install PowerShell on CentOS 7

Powershell is a terminal application for windows system such as windows 8 and windows 10. It can be used as a command line interface for windows system. PowerShell can also be installed on a Linux machine. In this article, you will learn about the installation procedure of PowerShell.

Installing PowerShell

To install PowerShell, it is necessary to download the package first, so use the following command to download it.

[root@linuxhelp ~]# wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.10/powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm

Once it is downloaded, install it by using yum or rpm command. Here in this example, yum command is used.

[root@linuxhelp ~]# yum install powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm -y
Loaded plugins: fastestmirror, langpacks
Examining powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm: powershell-6.0.0_alpha.10-1.el7.centos.x86_64
Marking powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm to be installed
Resolving Dependencies
-->  Running transaction check
--->  Package powershell.x86_64 0:6.0.0_alpha.10-1.el7.centos will be installed
-->  Processing Dependency: libunwind for package: powershell-6.0.0_alpha.10-1.el7.centos.x86_64
base                                                                                                                 | 3.6 kB  00:00:00     
extras                                                                                                               | 3.4 kB  00:00:00     
updates                                                                                                              | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                                        | 155 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                                    | 121 kB  00:00:04     
(3/4): updates/7/x86_64/primary_db                                                                                   | 2.2 MB  00:00:11     
(4/4): base/7/x86_64/primary_db                                                                                      | 5.6 MB  00:00:23     
Determining fastest mirrors
 * base: mirror.fibergrid.in
 * extras: mirror.fibergrid.in
 * updates: mirror.fibergrid.in
-->  Running transaction check
--->  Package libunwind.x86_64 2:1.1-5.el7_2.2 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  powershell.x86_64 0:6.0.0_alpha.10-1.el7.centos                                                                                           

Dependency Installed:
  libunwind.x86_64 2:1.1-5.el7_2.2                                                                                                          

Complete!

PowerShell is installed, launch it with the help of following command.

[root@linuxhelp ~]# powershell 
PowerShell 
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

If you want to view the list of the commands, you can use the following command inside the PowerShell terminal. It displays top 10 (alphabetical order) of the list.

PS /root>  (Get-Command)[0..9]                                                                                                               

CommandType     Name                                               Version    Source                                                       
-----------     ----                                               -------    ------                                                       
Function        Add-NodeKeys                                       0.0        PSDesiredStateConfiguration                                  
Function        AddDscResourceProperty                             0.0        PSDesiredStateConfiguration                                  
Function        AddDscResourcePropertyFromMetadata                 0.0        PSDesiredStateConfiguration                                  
Function        AfterAll                                           3.3.9      Pester                                                       
Function        AfterEach                                          3.3.9      Pester                                                       
Function        Assert-MockCalled                                  3.3.9      Pester                                                       
Function        Assert-VerifiableMocks                             3.3.9      Pester                                                       
Function        BeforeAll                                          3.3.9      Pester                                                       
Function        BeforeEach                                         3.3.9      Pester                                                       
Function        cd..                                                                                                            

Use following command, To view the current working directory.

PS /root>  pwd                                                                                                                               
Path 
---- 
/root

To list files and directory, you can use ls command or dir command as shown below.

PS /root>  ls                                                                                                                                
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures                         Public    Videos
Desktop         Downloads  Music          powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm  Templates
PS /root>  dir                                                                                                                               

    Directory: /root

Mode                LastWriteTime         Length Name                                                                                      
----                -------------         ------ ----                                                                                      
d-----           2/2/17   1:26 PM                Desktop                                                                                   
d-----           2/2/17   1:26 PM                Documents                                                                                 
d-----           2/2/17   1:26 PM                Downloads                                                                                 
d-----           2/2/17   1:26 PM                Music                                                                                     
d-----           2/2/17   1:26 PM                Pictures                                                                                  
d-----           2/2/17   1:26 PM                Public                                                                                    
d-----           2/2/17   1:26 PM                Templates                                                                                 
d-----           2/2/17   1:26 PM                Videos                                                                                    
------           2/2/17   6:47 PM           1505 anaconda-ks.cfg                                                                           
------           2/2/17   1:26 PM           1556 initial-setup-ks.cfg                                                                      
------           2/2/17  11:51 AM       40410715 powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm                                   

If you want to move to specific directory path, use the following command.

PS /root>  cd ./Desktop/                                                                                                             

In order to move to the home directory, run the following command.

PS /root/Desktop>  cd                                                                                                                    

You can list all the content of a particular directory with the help of the following command.

PS /root>  Get-ChildItem /                                                                                                                   

    Directory: /

Mode                LastWriteTime         Length Name                                                                                      
----                -------------         ------ ----                                                                                      
d----l           2/2/17   6:34 PM                bin                                                                                       
d-r---           2/2/17   6:47 PM                boot                                                                                      
d-----           2/2/17   1:26 PM                dev                                                                                       
d-----           2/2/17   2:08 PM                etc                                                                                       
d-----           2/2/17   6:46 PM                home                                                                                      
d----l           2/2/17   6:34 PM                lib                                                                                       
d----l           2/2/17   6:34 PM                lib64                                                                                     
d-----          6/10/14   5:41 AM                media                                                                                     
d-----          6/10/14   5:41 AM                mnt                                                                                       
d-----           2/2/17   2:08 PM                opt                                                                                       
d-r---           2/2/17   6:54 PM                proc                                                                                      
d-r---           2/2/17   2:06 PM                root                                                                                      
d-----           2/2/17   2:08 PM                run                                                                                       
d----l           2/2/17   6:34 PM                sbin                                                                                      
d-----          6/10/14   5:41 AM                srv                                                                                       
d-r---           2/2/17   6:54 PM                sys                                                                                       
d-----           2/2/17   2:09 PM                tmp                                                                                       
d-----           2/2/17   6:34 PM                usr                                                                                       
d-----           2/2/17   1:26 PM                var                                                                                      

If you want to create new file in the PowerShell terminal, use the following command.

PS /root>  New-Item -Path test.txt                                                                                                           

    Directory: /root

Mode                LastWriteTime         Length Name                                                                                      
----                -------------         ------ ----                                                                                      
------           2/2/17   2:14 PM              0 test.txt                                                                            

Use the following command to create a new directory.

PS /root>  New-Item -ItemType Directory -Path newdir                                                                                         

    Directory: /root

Mode                LastWriteTime         Length Name                                                                                      
----                -------------         ------ ----                                                                                      
d-----           2/2/17   2:15 PM                newdir              

In order to view the content of a file, use the following command.

PS /root>  Get-Content anaconda-ks.cfg                                                                                                       
#version=RHEL7
# System authorization information
auth --enableshadow --passalgo=sha512

# Use CDROM installation media
cdrom
# Run the Setup Agent on first boot
firstboot --enable
.
.
.
@multimedia
@print-client
@x11

%end

Use the following command to rename a file.

PS /root>  Move-Item test.txt sample.txt                                                                        

Use the following command to copy a file.

PS /root>  Copy-Item sample.txt copy.txt                                                                                         

Use the following command to remove a file.

PS /root>  Remove-Item copy.txt                                                                                               

Use the following command to remove a directory recursively.

PS /root>  Remove-Item newdir -Recurse                                                                                                       

Tags:
jayce
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

Really does power shell will work in linux?

A

Yes it will work in windows and linux

Q

Where do we find powershell latest release?

A

use the following link to find the latest version
https://github.com/PowerShell/PowerShell/releases/

Q

How to list contents in the particular directory in powershell?

A

you can list content of powershell by following command
# PS /root> Get-ChildItem /

Q

what Command used for removing directory in powershell?

A

the below option will remove directory recursively
PS /root> Remove-Item newdir -Recurse

Q

how to download the package of powershell in terminal?

A

use the following command to download the package of powershell
# wget https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.10/powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.