What this book covers
, Installation, Reference and Help, introduces the administrators to what .NET Core is, what its capabilities are, how its been implemented in Linux, and proceeds to introduce PowerShell. The chapter contains information on the history of PowerShell, how it is implemented on Unix-like systems, and how it differs from the currently-available shells.
, Introducing the Core and its Capabilities, takes the reader through how to install PowerShell, get around the documentation, search for information, discover cmdlets, and attach modules and providers to extend the capabilities of PowerShell.
, Preparing for Administration using PowerShell, prerequisites to efficient administration is a comfortable workspace. In this chapter, we customize our Terminal, learn how PowerShell behaves, and learn to think in PowerShell along with the various ways to use the cmdlets.
, First Steps in Administration using PowerShell, knows how PowerShell behaves, we start with basic utilities in PowerShell in this chapter, such as fetching the date and counting the returned objects. We work with processes and learn how to schedule them with the implementation of crontab in PowerShell.
, Passing data through pipelines, introduces the readers to use pipelines to leverage object-oriented model of PowerShell.
, Using Variables and Objects,takes the reader through defining and using variables effectively in scripts. Also, the chapter takes a deep dive into the objects returned by PowerShell cmdlets.
, Flow Control using Branches and Loops,takes the reader through building a logic that uses branching and looping, as the basic logical building blocks of scripts and functions.
, Working with Strings, takes the readers through using them to the benefit of administrators.
, Performing Calculations, would help the reader perform mathematical calculations within PowerShell.
, Using Arrays and Hash Tables, gives the user a good understanding of how arrays and hash tables work in PowerShell and how to use them.
, Handling Files and Directories, would take the reader through all that they need to know on file handling using PowerShell.
, Building Scripts and Functions, takes the user through creating scripts as a means of code reuse. Apart from writing a series of instructions to run scripts without interactions, the chapter takes the interactive scripts approach to enable better flexibility. Functions are a better way of leveraging PowerShell's potential in code reuse. This chapter also introduces the concept of functions as a step further from merely writing scripts.
, Advanced Concepts of Functions, shows the next step in the process of building functions, and packs the advanced capabilities that help build production-ready functions that have all functionalities of a cmdlet, such as parameter sets and complete help.
, Getting Under the Hood: Debugging and Error Handling, takes the readers through the various options available, that help scripters and administrators create reliable scripts. This chapter also introduces the reader to the different types of errors, reading errors in PowerShell, and handling them gracefully.
, Working with the Environment, introduces the reader to how PowerShell handles the environment. The reader would learn to use the environment variables, know how a command was invoked, and other important aspects that would make using PowerShell easier.
, Security in PowerShell, introduces the reader to the security features available in PowerShell, and how to turn them on and off.
, Enterprise Administration using PowerShell,enables the reader to tap into the power of PowerShell and start managing computers in an enterprise using PowerShell.
, Best Practices Round-up, the best practices are re-iterated so as to ensure that the reader remembers them, along with explanations to why theyre considered best practices.
, PowerShell and Cloud Operations, moves away from on-premises environments to see how we can administer Azure and AWS cloud platforms using the available options.
, Using PowerShell for SQL Database Management, designes to teach you the fundamentals of using PowerShell to manage your SQL Servers, as well as perform development activities on them. It includes the installation and configuration procedures and also covers some basic database administration tasks using SMO libraries in PowerShell.
Preface
PowerShell 6.0 Linux Administration Cookbook will take you through a complete tour of understanding .NET Core, PowerShell in general, PowerShell on Linux for management and automation. This book will also cover advanced concepts on how to use PowerShell and manage Docker containers, Cloud, VMware and SQL databases.
Installation, Reference and Help
In this chapter we're going to cover the following recipes:
- Installing PowerShell
- Fetching help information in PowerShell
- Fetching help information for a specific cmdlet
- Updating help
- Searching help for keywords
- Looking for help information specific to a parameter
- Exploring the about_ topics
- Discovering cmdlets
- Finding modules
- Installing modules from the repository
- Listing the various providers in PowerShell
Introduction
It all begins with the installation of PowerShell on your system. Installation of PowerShell is simple and straightforward. Since PowerShell is open source, its source code is available on the arguably largest platform for open source projects, GitHub. At the moment, Windows, Debian (and Ubuntu), RedHat Linux (and CentOS), Fedora and macOS are officially supported by the PowerShell project. Arch Linux and Kali Linux are supported by the community. Community support is also available for the AppImage edition of PowerShell that can be used on most of the modern-day Linux distributions.
An AppImage is a way of packaging applications to run on Linux distributions. Every application has its dependencies. On Linux, the package managers manage the installation of the dependencies while installing the packages. An AppImage package, on the other hand, packs all the necessary dependencies within itself. An AppImage can run in portable mode, or be installed on the system, based on user preference.
PowerShell is, as of writing of this chapter, experimentally available for Windows on ARM and Raspbian Stretch.
Installing PowerShell
Basically, in Linux, it should be fairly simple to get the source code and build the application from the source code using make. This approach should work for PowerShell as well. However, as noted above, official support and community support are available only for a few distributions. We would focus on installing PowerShell on Ubuntu and CentOS since they are two of the most popular Linux distributions.
PowerShell is available in two releases: stable and preview. The stable releases are suitable for production environment since they're more reliable. The preview releases are for test environments where the administrators are allowed to feel a little adventurous, and are willing to report bugs they come across along with providing feedback on the capabilities.
Getting Ready
Getting ready to install PowerShell on your computer is simple. You simply need a working Linux computer, which you have administrator privileges on. Depending on what mode you pick to install PowerShell, you may or may not need a package manager. Chances are, your Linux distribution already has a package manager available.