HowTo Install Microsoft PowerShell: Difference between revisions

From MediaWiki
Jump to navigationJump to search
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
__TOC__
__TOC__
= Overview =
= Overview =
'''[https://docs.microsoft.com/en-us/powershell/scripting/powershell-scripting?view=powershell-6 PowerShell]''' is built on the '''[https://en.wikipedia.org/wiki/.NET_Framework .NET Framework]''', PowerShell is a task-based command-line shell and scripting language; it is designed specifically for system administrators and power-users, to rapidly automate the administration of multiple operating systems (Linux, macOS, Unix, and Windows) and the processes related to the applications that run on those operating systems.


= Learning PowerShell =
Whether you're a Developer, a DevOps or an IT Professional, this '''[https://github.com/PowerShell/PowerShell/tree/master/docs/learning-powershell doc]''' will help you getting started with PowerShell. In this document we'll cover the following: installing PowerShell, samples walkthrough, PowerShell editor, debugger, testing tools and a map book for experienced bash users to get started with PowerShell faster.


= PowerShell Installation Instructions =
= PowerShell Installation Instructions =
PowerShell Core, for Linux, is published to package repositories for easy installation (and updates). Below is the preferred method for installation for the "'''nst'''" sudo user:
  <span style="color: green;"># Register the Microsoft signature key</span>
  <span style="color: green;"># Register the Microsoft signature key</span>
  <pre>sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc;</pre>
  <nowiki>sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc;</nowiki>
   
   
  <span style="color: green;"># Register the Microsoft RedHat repository</span>
  <span style="color: green;"># Register the Microsoft RedHat repository</span>
  <pre>curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo;</pre>
  <nowiki>curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo;</nowiki>
   
   
  <span style="color: green;"># Update the list of products</span>
  <span style="color: green;"># Update the list of products</span>
  <pre>sudo dnf update;</pre>
  sudo dnf update;
   
   
  <span style="color: green;"># Install a system component</span>
  <span style="color: green;"># Install a system component</span>
  <pre>sudo dnf install compat-openssl10;</pre>
  sudo dnf install compat-openssl10;
   
   
  <span style="color: green;"># Install PowerShell</span>
  <span style="color: green;"># Install PowerShell</span>
  <pre>sudo dnf install -y powershell;</pre>
  sudo dnf install -y powershell;
   
   
  <span style="color: green;"># Start PowerShell</span>
  <span style="color: green;"># Start PowerShell</span>
  <pre>pwsh;</pre>
  pwsh;
<span style="color: green;"># Or Instead Install the Latest PowerShell Preview Version</span>
sudo dnf install -y powershell-preview;
<span style="color: green;"># Start the PowerShell Preview Version</span>
pwsh-preview;
 
= Get the Installed PowerShell Version =
Use the Automatic variable: "'''$PSVersionTable'''" to get PowerShell versioning information. Automatic variables store state information for PowerShell. These variables are created and maintained by PowerShell. The ''Get-Variable'' command displays the currently defined Automatic variables.
 
<span style="color: green;"># Get PowerShell Version</span>
[nst@d630 ~]$ pwsh-preview
PowerShell v6.1.0-preview.3
Copyright (c) Microsoft Corporation. All rights reserved.
<nowiki>https://aka.ms/pscore6-docs</nowiki>
Type 'help' to get help.
PS /home/nst> <span style="color: green;">$PSVersionTable</span>
Name                          Value
----                          -----
PSVersion                      6.1.0-preview.3
PSEdition                      Core
GitCommitId                    v6.1.0-preview.3
OS                            Linux 4.17.3-200.fc28.x86_64 #1 SMP Tue Jun 26 14:17:07 UTC 2018
Platform                      Unix
PSCompatibleVersions          {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion          1.1.0.1
WSManStackVersion              3.0
PS /home/nst> <span style="color: green;">exit</span>
[nst@d630 ~]$

Latest revision as of 08:20, 5 July 2018

Overview

PowerShell is built on the .NET Framework, PowerShell is a task-based command-line shell and scripting language; it is designed specifically for system administrators and power-users, to rapidly automate the administration of multiple operating systems (Linux, macOS, Unix, and Windows) and the processes related to the applications that run on those operating systems.

Learning PowerShell

Whether you're a Developer, a DevOps or an IT Professional, this doc will help you getting started with PowerShell. In this document we'll cover the following: installing PowerShell, samples walkthrough, PowerShell editor, debugger, testing tools and a map book for experienced bash users to get started with PowerShell faster.

PowerShell Installation Instructions

PowerShell Core, for Linux, is published to package repositories for easy installation (and updates). Below is the preferred method for installation for the "nst" sudo user:

# Register the Microsoft signature key
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc;

# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo;

# Update the list of products
sudo dnf update;

# Install a system component
sudo dnf install compat-openssl10;

# Install PowerShell
sudo dnf install -y powershell;

# Start PowerShell
pwsh;

# Or Instead Install the Latest PowerShell Preview Version
sudo dnf install -y powershell-preview;

# Start the PowerShell Preview Version
pwsh-preview;

Get the Installed PowerShell Version

Use the Automatic variable: "$PSVersionTable" to get PowerShell versioning information. Automatic variables store state information for PowerShell. These variables are created and maintained by PowerShell. The Get-Variable command displays the currently defined Automatic variables.

# Get PowerShell Version
[nst@d630 ~]$ pwsh-preview 
PowerShell v6.1.0-preview.3
Copyright (c) Microsoft Corporation. All rights reserved.

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

PS /home/nst> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.3
PSEdition                      Core
GitCommitId                    v6.1.0-preview.3
OS                             Linux 4.17.3-200.fc28.x86_64 #1 SMP Tue Jun 26 14:17:07 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /home/nst> exit
[nst@d630 ~]$