Skip to main content

PowerShell Core for Linux Admins

Course

Intro Video

Photo of Corey Knapp

Corey Knapp

Training Architect

Length

08:00:00

Difficulty

Intermediate

Videos

51

Hands-on Labs

6

Course Details

This intermediate-level course teaches the concepts of using PowerShell Core with Linux.

We will cover everything from installing PowerShell on Linux (including Visual Studio Code) to learning how to use cmdlets and variables. We'll then dive into using more advanced components of PowerShell Core like strings, arrays, hash tables, and logic flow.

Finally, we'll go into how to accomplish some everyday management tasks in Linux using PowerShell. These include remote administration, installing Docker, working with SQL Server, and managing Azure resources.

Syllabus

Welcome to the Course

Course Introduction

00:01:34

Lesson Description:

This intermediate-level course teaches the concepts of using PowerShell Core with Linux. We will cover everything from installing PowerShell on Linux, including Visual Studio Code, to learning how to use cmdlets and variables. We'll then dive into using more advanced components of PowerShell Core like strings, arrays, hash tables, and logic flow. Finally, we'll go into how to accomplish some everyday management tasks in Linux using PowerShell like remote administration, installing Docker, working with SQL Server, and managing Azure resources.

About the Training Architect

00:00:21

Lesson Description:

Greetings! Welcome to this PowerShell for Linux Admins course! My name is Corey Knapp, and I'll be the training architect for this course. I'm excited to help on this journey exploring PowerShell from the Linux perspective! I'd love you hear from you. Please feel free to reach out to me in the community or in the Community Slack channel. And as always, keep on Learning!

Linux and Microsoft Can Coexist?

Introduction

00:00:55

Lesson Description:

In this section, we'll start by taking a look at where PowerShell came from, where it can be installed from, when and why it became open source, and take a look at the Microsoft PowerShell documentation. The official Microsoft documentation for PowerShell can be found at https://docs.microsoft.com/en-us/powershell/.

Open Source PowerShell

00:02:07

Lesson Description:

In this lesson, we'll dive into why Microsoft took PowerShell the open-source route, what had led to the decision, and how PowerShell can help Linux and Windows admins.

Where to Find PowerShell Core and How Licensing Works

00:02:34

Lesson Description:

In this lesson, we'll take a look at the MIT Licensing under which PowerShell is supported as well as the PowerShell Github repository where PowerShell can be obtained. Link for PowerShell Github: https://github.com/powershell/powershell

Getting Started

00:02:25

Lesson Description:

In this lesson, we look at the Microsoft "Getting Started" documentation for PowerShell. This includes instructions for installing PowerShell, information on PowerShell editors, debugging tools, as well as a comparison chart between Bash commands and PowerShell cmdlets. Link to "Getting Started" documentation: https://github.com/PowerShell/PowerShell/tree/master/docs/learning-powershell

Installation

Introduction and Prerequisites

00:05:27

Lesson Description:

This lesson goes into detail of the prerequisites for installing PowerShell for Linux. We walk through the process of updating the Linux operating system, installing an XFCE desktop environment, and installing XRDP for remote desktop access into the Linux system.

Installing PowerShell Core

00:01:44

Lesson Description:

This lesson contains a quick demonstration on how to install PowerShell for Linux, including updating the Universe repository, installing the PowerShell application, and launching PowerShell using the pwsh command.

Installing Visual Studio Code

00:05:05

Lesson Description:

In this lesson, we go through the steps necessary to install Visual Studio Code in Linux. To follow along with the demo, please follow these steps for installing VS Code on Ubuntu. 1. sudo apt update 2. sudo apt install software-properties-common apt-transport-https wget 3. wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - 4. sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" 5. sudo apt update 6. sudo apt install code

Installing Azure Data Studio

00:03:13

Lesson Description:

In this lesson, we go through the steps necessary to install Azure Data Studio on Linux.

Starting to Use PowerShell Core on Linux

Using PowerShell Core in the Terminal

00:02:53

Lesson Description:

In this lesson, we look at using PowerShell in the Linux terminal. We talk about the different ways to open PowerShell in Linux, as well as some basic cmdlets such as Get-Command and Get-Help.

Using PowerShell Core in Visual Studio Code

00:05:33

Lesson Description:

In this lesson, we look at the different components of Visual Studio Code when using PowerShell in Linux. This includes how to install extensions in VS Code, perusing the different help and menu options, inserting cmdlets from the PowerShell cmdlet library, and many other features.

Comments in PowerShell Core

00:03:04

Lesson Description:

Comments are lines of code in a PowerShell script meant to be used as an informal version of help or offer advice and perspecive on why a script was written a certain way. This lesson introduces the concept of comments in PowerShell and how we can use them to build well written, comprehensive code, and adhere to best practices as much as possible.

Commands in PowerShell Core: Cmdlets

00:07:54

Lesson Description:

In this lesson, we start working with cmdlets in PowerShell, specifically Get-Command and Get-Help. Mastering the use of these two cmdlets enables one to find any required cmdlet when using PowerShell.

Debugging PowerShell in Visual Studio Code

00:04:10

Lesson Description:

In this lesson, we go through an introduction of how to debug PowerShell scripts and code using Visual Studio Code.

What Are Aliases?

00:03:24

Lesson Description:

A PowerShell alias is another name assigned to a cmdlet. PowerShell cmdlet names follow a Verb-Noun syntax which can be cumbersome for some to type and use. To minimize typing, and to make it easier for users accustomed to other shells like Windows Command Prompt or Unix shells, Windows PowerShell supports the concept of an alias. Simply, an alias is an alternate name for a cmdlet. In this lesson, we'll take a look at the concept and use of aliases in your everyday coding.

Leveraging PowerShell Cmdlets in Linux

Introduction

00:01:47

Lesson Description:

In this lesson, we introduce some new PowerShell concepts including pipelines and providers. We also talk about why we should use PowerShell, and what the verb-noun syntax is. By the end of this section, we'll have provided an understanding of the basic core PowerShell concepts which will prepare us for the lessons later in this course.

How Do Pipelines Work?

00:01:33

Lesson Description:

Microsoft PowerShell is a powerful scripting language and administrative framework, initially only for Windows, that has now opened up for Linux and MacOS users. One of the key elements that makes it so powerful is the pipeline: the assembly line of data and results that moves between and through cmdlets. In this lesson, we talk about how to glue things together, or more specifically, how to take the output or results from one PowerShell cmdlet and send it into another for further processing.

Pipelines and Their Implications for Linux Admins

00:06:53

Lesson Description:

What makes pipelines so special, especially from the Linux perspective? Pipelines are arguably the most valuable concept used in command-line interfaces. When used properly, pipelines reduce the effort of using complex commands and make it easier to see the flow of work for the commands. Each command in a pipeline (called a pipeline element) passes its output to the next command in the pipeline, item-by-item. Commands don't have to handle more than one item at a time. The result is reduced resource consumption and the ability to begin getting the output immediately.

PowerShell Providers

00:08:28

Lesson Description:

What is a PowerShell provider? PowerShell providers are programs that provide access to specialized data stores for easier viewing and management. The data appears on a drive, and we access the data in a path like we would on a hard disk drive. This lesson introduces the concept of PowerShell providers including how to access and how to create them.

Working with Variables in PowerShell

Introduction to Variables

00:13:15

Lesson Description:

PowerShell works with objects. PowerShell lets you create named objects known as variables. Variable names can include the underscore character and any alphanumeric characters. When used in PowerShell, a variable is always specified using the $ character followed by variable name. This lesson takes a look at how we can use variables in our scripts and code.

PowerShell Built-In Variables

00:03:05

Lesson Description:

What are built-in variables in PowerShell? PowerShell defines and populates several variables automatically. These variables let you access information about the execution environment, PowerShell preferences, and more. In this lesson, we look at the concept of built-in variables, some examples, and how they are used.

Cmdlets for Working with Variables

00:05:01

Lesson Description:

How can we work with variables and cmdlets in PowerShell? In truth, almost all of the cmdlets in PowerShell can be used with PowerShell. In this lesson, we look at some common uses and ways that we can export information directly into variables in PowerShell.

Strings, Arrays, and Hashtables

Basics of Strings

00:08:02

Lesson Description:

A string is a data type used in programming (e.g. an integer or floating point unit), but it is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers. More specifically, in PowerShell, it is simply an object with a System.String type. A string can be defined in PowerShell by using single or double-quotes. In this lesson, we'll look at creating and manipulating strings as well as the benefits of using them.

String Interpolation

00:06:08

Lesson Description:

String interpolation is the way of displaying the value of variables by surrounding them with quotations. When done correctly, the output displayed by PowerShell prints the value of the variable instead of the variable name itself. In this lesson, we'll go through the different way string interpolation can be used, including backticks and expressions. Successful use of string interpolation can make our code more efficient and reusable.

String Formatting

00:11:37

Lesson Description:

Windows PowerShell provides access to the .NET Framework composite formatting feature. Composite formatting takes a list of objects and a composite formatting string as input. These consist of indexed place holders called format items. The output is a string that consists of the original text intermixed with the string representations of the objects in the list. In this lesson, we'll look at different examples of string formatting and use cases for each one.

Arrays

00:06:36

Lesson Description:

What is an array? An array is a data structure designed to store a collection of items. The items can be the same type or different types. To create and initialize an array, we assign multiple values to a variable. The values stored in the array are delimited with a comma and separated from the variable name by the assignment operator (=). In this lesson, we look at using arrays in PowerShell and some of their benefits.

Hash Tables

00:07:09

Lesson Description:

What is a hash table? A PowerShell hash table is a data structure of key/value pairs. A key/value pair is essentially a set of two elements related in some manner. In its simplest form, a hash table is just a way to store one or more sets of item names and item values. In this lesson, we look at different examples of hash tables in PowerShell and different ways in which we can use them.

Understanding Logic Flow

Controlling Logic Flow

00:08:54

Lesson Description:

What is logic flow? As we begin to write scripts or commands that interact with unknown data, the concepts of looping and flow control become increasingly important. PowerShell’s looping statements and commands let us perform an operation (or set of operations) without having to repeat the commands themselves. This includes tasks such as doing something a specified number of times, processing each item in a collection, or working until a certain condition comes to pass. In this lesson, we investigate how to implement logic flow and which situations it is best suited for.

Loops

00:08:47

Lesson Description:

What are loops? A loop is a sequence of statements specified once but which may be carried out several times in succession. Loop structures include while, do while, do until, for, and foreach. In this lesson, we look at each kind of loop and when it is beneficial to use each one.

Script Blocks

00:03:21

Lesson Description:

In the PowerShell programming language, a script block is a collection of statements or expressions that can be used as a single unit. A script block can accept arguments and return values. A script block returns the output of all the commands in the script block, either as a single object or as an array. In this lesson, we look at the different reasons to use script blocks and walk through different examples.

Advanced Functions

Introduction to Functions

00:07:24

Lesson Description:

When first starting out writing PowerShell scripts, we're not necessarily concerned about things such as modularity, reusability, and best practices. We're just getting our feet wet. However, as time goes on, we'll soon realize that we begin repeating ourselves in code. One thing to notice is the need to do the same thing over and over keeps getting greater. We could just copy and paste that same code, but that's not a sustainable solution. Instead, why not create small "building blocks" in code we can resuse? It's time to start creating PowerShell functions.

Getting Help

00:01:29

Lesson Description:

When dealing with functions in PowerShell, it's important to know where the corresponding help documentation is. In this lesson, we'll do just that and show where help can be found. This makes sure we're not up a creek without a paddle.

Pipelining Functions

00:03:49

Lesson Description:

When beginning to learn Windows PowerShell, one soon finds themselves neck-deep in objects. Objects are one of the fundamental concepts of what makes PowerShell so user-friendly and powerful at the same time. Diving deeper into the language, the next concept that one typically stumbles over is the pipeline. So let's take our PowerShell skills to the next level by incorporating pipeline input abilities into our advanced functions!

Writing Advanced Functions

00:03:17

Lesson Description:

PowerShell provides two different kinds of functions: basic and advanced. Basic functions are just that, basic. They are the simplest form a function can take. Basic functions do not allow us to do things like accept pipeline input, control streams, and so on. For those options, we have to write advanced functions. But what makes a basic function advanced? Let's find out.

Writing Cmdlets

00:01:17

Lesson Description:

Ever wondered if it's possible to write a PowerShell function that will have the same look and feel as PowerShell cmdlets delivered by Microsoft? Well, the simple answer is yes. The goal of this lesson is to show how to achieve this!

Importing and Exporting CSV

00:01:58

Lesson Description:

The PowerShell Export-Csv cmdlet and the PowerShell Import-Csv cmdlets allow administrators to import CSVs via foreach loop, use Export-Csv to append CSVs, and export arrays to a CSV file and a whole lot more! In this lesson, we show how we can use PowerShell to manage CSVs.

Output Variables and Common Parameters

00:01:33

Lesson Description:

Take a look at the help for any PowerShell cmdlet and notice <CommonParameters> at the end of each one's syntax list. What does this mean? PowerShell has a set of parameters that the shell itself adds to every cmdlet. In other words, the developer of a cmdlet doesn't need to code these. They're just there, like magic. They're also added to the scripts and functions we write in the shell. In this lesson, we take a look at what these common parameters are, what they do, and specific use cases for the -outvariable common parameter.

Creating and Checking Modules

00:01:14

Lesson Description:

What if we could turn our very own functions into our very own modules? Well, in Powershell, we can! In this lesson, we'll go through the steps necessary to turn that function into a module we can call whenever weu want. We'll also take a look at what's needed to fully complete this process.

Error Handling

00:03:12

Lesson Description:

Why handle errors? Error handling may take some extra time to create. However, it can really save us time in the long run. Let's take a look at how in this lesson.

Adding Help to Our Functions

00:02:56

Lesson Description:

One of the greatest tools to assist with learning PowerShell is the help system, specifically the Get-Help cmdlet. What if we could create the same kind of great help documentation for our own functions and cmdlets? This lesson teaches how to do just that!

Loading Functions from Another Script

00:00:55

Lesson Description:

Dot-sourcing is a concept in PowerShell that allows us to reference code defined in another script. When we're writing PowerShell scripts, then there always seems to come a time when a single script isn’t enough. If we're working on a large script, then it's important to keep our scripts simple and reusable so we can keep our script block as modular. Dot-sourcing is a way to do just that. Other than building new modules, dot-sourcing is a better way to make sure that code in another script is available when we need it. Let's find out how!

What Else Can We Do with PowerShell Core in Linux?

PowerShell Core as Our Default Shell

00:01:11

Lesson Description:

This quick lesson shows how to configure Linux so that default shell is PowerShell. Why would we do that? Well, why not? Let's find out how!

Remoting and Bash Integration

00:01:17

Lesson Description:

Does PowerShell allow us to remote into both Windows and Linux machines? Does it allow us to gather relevant data from those machines? Absolutely! In this lesson, we look at the steps needed to accomplish this.

Setting Up for Remote Administration

00:03:16

Lesson Description:

Continuing on from our last lesson, let's dive deeper into the world of remote administration with PowerShell.

Working with SQL Server Using PowerShell Core

00:06:01

Lesson Description:

Ever want to manage MS SQL Server from Linux? Well, now we can with PowerShell. In this lesson, we look at how to connect to that SQL database and more.

Working with Azure

00:06:06

Lesson Description:

One of the biggest bonuses of working with PowerShell is the ability to start working in the Cloud with Microsoft Azure. In this lesson, learn to connect to Azure and more!

Creating Azure Storage Accounts

00:07:49

Lesson Description:

Continuing on from connecting to Azure, let's start working with Azure Storage accounts. In this lesson, we create those accounts and see how it all works on the back end with PowerShell.

Creating Azure Virtual Machines

00:03:30

Lesson Description:

And finally, what good would working in Azure be if we couldn't spin up some virtual machines with PowerShell? In this lesson, we create virtual machines via the PowerShell CLI and show how much more powerful PowerShell is compared to the GUI.

The Final Chapter

Course Summary

00:01:10

Lesson Description:

It's over already? Thanks for taking and completing this course on PowerShell for Linux admins. We've covered a variety of topics including:What PowerShell is and why it is now open source. Installing PowerShell, Visual Studio Code, and Azure Data Studio. Cmdlets, variables, aliases, functions, arrays, and hash tables. Creating cmdlets and advanced functions. Linux administration tasks that can be managed from PowerShell.It's been a pleasure to present this content. On to the next course. Until then, keep on learning!

What's Next?

00:01:35

Lesson Description:

What's next? How do we keep leveling up our PowerShell skills to the next level? Imitate a Bash script or PowerShell script found online and adapt it or augment it as necessary. Convert a script used in Linux every day into a PowerShell script. The ideas are endless. Check the PowerShell websites and blogs out there. Here's to becoming the next PowerShell guru!

Take this course and learn a new skill today.

Transform your learning with our all access plan.

Start 7-Day Free Trial