Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PowerShell 7 Workshop

You're reading from   PowerShell 7 Workshop Learn how to program with PowerShell 7 on Windows, Linux, and the Raspberry Pi

Arrow left icon
Product type Paperback
Published in Feb 2024
Publisher Packt
ISBN-13 9781801812986
Length 468 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Nick Parlow Nick Parlow
Author Profile Icon Nick Parlow
Nick Parlow
Arrow right icon
View More author details
Toc

Table of Contents (23) Chapters Close

Preface 1. Part 1: PowerShell Fundamentals
2. Chapter 1: Introduction to PowerShell 7 – What It Is and How to Get It FREE CHAPTER 3. Chapter 2: Exploring PowerShell Cmdlets and Syntax 4. Chapter 3: The PowerShell Pipeline – How to String Cmdlets Together 5. Chapter 4: PowerShell Variables and Data Structures 6. Chapter 5: PowerShell Control Flow – Conditionals and Loops 7. Chapter 6: PowerShell and Files – Reading, Writing, and Manipulating Data 8. Chapter 7: PowerShell and the Web – HTTP, REST, and JSON 9. Part 2: Scripting and Toolmaking
10. Chapter 8: Writing Our First Script – Turning Simple Cmdlets into Reusable Code 11. Chapter 9: Don’t Repeat Yourself – Functions and Scriptblocks 12. Chapter 10: Error Handling – Oh No! It’s Gone Wrong! 13. Chapter 11: Creating Our First Module 14. Chapter 12: Securing PowerShell 15. Part 3: Using PowerShell
16. Chapter 13: Working with PowerShell 7 and Windows 17. Chapter 14: PowerShell 7 for Linux and macOS 18. Chapter 15: PowerShell 7 and the Raspberry Pi 19. Chapter 16: Working with PowerShell and .NET 20. Answers to Activities and Exercises 21. Index 22. Other Books You May Enjoy

What is PowerShell 7?

PowerShell is a scripting language and an alternative to the command-line interface. PowerShell is an automation tool consisting of (at least) three parts:

  • A shell, like the Command Prompt in Windows or the Terminal in Linux or macOS
  • A scripting language
  • A configuration management framework called Desired State Configuration (DSC)

In practice, when we talk about PowerShell, we’re usually talking about the scripting language. Usage of the shell is largely intuitive to the user, as we’ll see, and while we’ll talk about DSC later, in my experience, most people don’t use it as much as they should.

The first version of PowerShell grew out of a project called Monad, which was an attempt by Jeffrey Snover to replicate Unix tools on Windows. He realized that one of the fundamental drawbacks of Unix tools is that they output a bytestream (usually text), and so a lot of effort is wasted on searching, formatting, and extracting the output of commands before you can act on that output. Monad was written to output objects that could be input straight into another command. We’ll cover this in more detail when we get to Chapter 4, PowerShell Variables and Data Structures. PowerShell 1.0 was released in 2006, but in my opinion, it didn’t really take off until PowerShell 2.0 was released in 2009, and Microsoft started re-engineering the administrative interfaces of major pieces of software such as Exchange Server 2010 to make use of it. Other opinions are available.

At the time of writing, there are two main flavors of PowerShell: Windows PowerShell, which comes bundled with both server and desktop versions of Windows, and PowerShell 7, which must be downloaded and installed. The latest (and allegedly final) version of Windows PowerShell, v5.1, is built on .NET Framework 4.5, the proprietary software framework that is bundled with Windows and underpins many of Microsoft’s products. PowerShell 7.0 was built on .NET Core 3.1, a simplified, open source implementation of .NET. However, since version 7.2, PowerShell has been built on .NET 6.0. This unified version of .NET is a replacement for both .NET Framework and .NET Core, and was released in November 2020.

Because of the fundamental differences between Windows PowerShell 5.1 and PowerShell 7.x, there can be some differences in how they work on the Windows platform. These will be discussed in Chapter 13, Working With PowerShell 7 and Windows.

We’ll find it useful to summarize some of the key differences in the following table:

Parameters

Windows PowerShell

PowerShell 7.2

Platform

x64, x86 only

x64, x86, arm32, arm64

OS

Windows

Windows, Linux, macOS

.NET Version

.NET Framework 4.5

.NET 6.0

License Type

Proprietary

Open source

No. of Native Commands

1588 (in vanilla Windows 10)

1574 (in vanilla Windows 10)

290 (in Ubuntu 20.04)

Table 1.1 – Some differences between Windows PowerShell and PowerShell 7

In this section, we have covered what PowerShell is, and how it differs from Windows PowerShell. In the next section, we’ll look at why PowerShell 7 exists and see what makes it special.

You have been reading a chapter from
PowerShell 7 Workshop
Published in: Feb 2024
Publisher: Packt
ISBN-13: 9781801812986
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image