PowerShell
The ultimate beginners guide to learn PowerShell step-by-step
Mark Reed
Copyright 2020 - All rights reserved.
It is not legal to reproduce, duplicate, or transmit any part of this document in either electronic means or in printed format. Recording of this publication is strictly prohibited and any storage of this document is not allowed unless with written permission from the publisher except for the use of brief quotations in a book review.
Table of Contents
Introduction
Computer system administration can be difficult, especially when you deal with large or complex computing systems. Even in the case where systems are smaller and less complex, routine maintenance can also represent another challenge. PowerShell is a system administration and configuration technology that is designed specifically to address these challenges.
Learning a new technology within the fast and vast field of computing system administration can be daunting and very difficult, especially when involved technologies are both fast-changing and difficult to grasp. In these situations, it is useful to have a comprehensive guide that can help you learn the most important components of the technology in question quickly. In addition, the guide should summarize the learning items into a compact set that can help you translate the technology into everyday use.
This is precisely what this book is for PowerShell 7.0 does for beginners. This book will provide you, as the reader, with a comprehensive foundation to a new and exciting technology in the form of PowerShell 7.0. This book has the crisp rigor of computer programming presented in a compact manner while maintaining the full comprehensive scope. The ideas presented here capture the best system administration and configuration technologies from the fast-changing landscape of the Microsoft .NET platform. These ideas are presented to you in a manner that is easy to learn so that you can quickly put them into practical use.
After reading this book, you can begin to use the most important technologies in PowerShell 7.0 right away. This will not only improve how you manage computing systems in the present computing landscape, but also how you will adapt to future developments.
PowerShell is a part of some of the most important Microsoft certifications ("Online IT Training Videos, IT Certification Training | CBT Nuggets", 2019), including Microsoft Certified Solutions Associate: Windows Server 2016, Microsoft Certified Solutions Expert: Productivity, Microsoft Certified: Azure Administrator and MCSE: Mobility.
There are nine categories of scripting languages and roughly 192 languages in total ("Scripting Languages", 2018), with each language evolving in line with the fast-paced developments in the field of computer software. PowerShell became open-source in 2016, thus laying the foundation for the language to evolve at an extremely fast pace. This book will equip you with the skills to not only quickly go from a beginner to an intermediate in one of these languages but also to put the language to practical use very quickly.
PowerShell 7.0 utilizes the latest developments in Microsoft .NET platform stack architecture in the form of the Standard 2.0 library and the .NET Core 3.1 stack ("Announcing The Powershell 7.0 Release Candidate | Powershell", 2019). This book will help you learn how to put to practical use the most important components of these developments within PowerShell 7.0 instantly. Not only will you begin creating custom administration and configuration tools for your computing environments, but you will be able to do so for future PowerShell versions as well.
PowerShell 7.0 can be utilized in various operating system environments (Windows, Linux, and macOS environments), both in local environments and in the cloud. This book will effortlessly equip you with the compact set of requisite knowledge to utilize PowerShell 7.0 in each of these environments in no time.
I can promise that with this book, you will be automating repetitive tasks, running custom encryption protocols, and overseeing large-scale management over complex computing systems effortlessly in little to no time at all. In addition, you will be able to use many of the solutions to real-world problems outlined in this book in your day-to-day tasks (Arntzen, 2019).
It is imperative to remember, however, that any computing system, even a simple example such as your laptop, will continue to grow more complex and difficult to manage with time. The solution to most of your problems may be outlined in the next pages.
Chapter One:
PowerShell Components
In this chapter we will explore the components of PowerShell 7.0. The components of PowerShell are the user interface (UI) with which users interact with PowerShell as well as related software that houses PowerShell components used to enhance the user interface. The related software comprises Visual Studio Code (VS Code) and the PowerShell Gallery. VS Code is a script editor that houses PowerShell integrated scripting environment features. The PowerShell Gallery is a PowerShell content central repository which can be accessed from PowerShell. In this chapter we will also go through the steps of downloading and installing the first two components (namely, PowerShell and VS Code). The installation instructions assume that you have an internet connection.
PowerShell 7.0 is a GitHub project that was made open source in 2016, and this chapter will look at how to source material available on GitHub when starting PowerShell 7.0. The main PowerShell 7.0 installation method described for the Windows and Linux operating systems uses the .NET Core SDK (Software Development Kit). In the case of macOS, the main method is by direct download, but the .NET Core SDK method will also be described. In the case of ARM, (Acorn RISC Machine) devices, a Windows method and a Linux method will be outlined.
Installing PowerShell 7.0 on Windows
The simplest method to install PowerShell 7.0 on Windows is to use the .NET Core SDK ("Installing Powershell Core On Windows - Powershell", 2019).
The first step is to have .NET Core SDK installed. This is done by downloading an installer for your Computer Processing Unit (CPU), namely, (x64 or x86) from https://dotnet.microsoft.com/download/dotnet-core/3.1 ("Install .NET Core SDK On Windows, Linux, And macOS - .NET Core", 2019).
The second step is to run the installer and follow the Wizard prompts. The third step is to check that everything installed properly by opening a command prompt and running this command (".NET Tutorial | Hello World In 10 Minutes", 2019):
>dotnet
If dotnet results in a dotnet help file printout, then the installation ran successfully. If the command results in an error command stating that dotnet is not recognized as a command, then try re-opening the command prompt.
The fourth step is to run this command to install PowerShell as a .NET Global tool ("Installing Powershell Core On Windows - Powershell", 2019):
>dotnet tool install --global PowerShell
The remainder of the methods can be found at:
https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7
Installing PowerShell 7.0 on Linux
PowerShell 7.0 support is available for Ubuntu (16.04, 18.04, 18.10 and 19.04), Debian (8.9.10), CentOS 7, Fedora (27,28), Red Hat Enterprise Linux (RHEL) 7, openSUSE (42.3, LEAP 15) and Arch Linux ("Installing Powershell Core On Linux - Powershell", 2019). The simplest method to install PowerShell 7.0 on Linux is to use the .NET Core SDK ("Installing Powershell Core On Linux - Powershell", 2019).