Book Image

PowerShell Core for Linux Administrators Cookbook

By : Prashanth Jayaram, Ram Iyer
Book Image

PowerShell Core for Linux Administrators Cookbook

By: Prashanth Jayaram, Ram Iyer

Overview of this book

PowerShell Core, the open source, cross-platform that is based on the open source, cross-platform .NET Core, is not a shell that came out by accident; it was intentionally created to be versatile and easy to learn at the same time. PowerShell Core enables automation on systems ranging from the Raspberry Pi to the cloud. PowerShell Core for Linux Administrators Cookbook uses simple, real-world examples that teach you how to use PowerShell to effectively administer your environment. As you make your way through the book, you will cover interesting recipes on how PowerShell Core can be used to quickly automate complex, repetitive, and time-consuming tasks. In the concluding chapters, you will learn how to develop scripts to automate tasks that involve systems and enterprise management. By the end of this book, you will have learned about the automation capabilities of PowerShell Core, including remote management using OpenSSH, cross-platform enterprise management, working with Docker containers, and managing SQL databases.
Table of Contents (19 chapters)

Showing progress of execution

The whole point of automation is that it helps handle repetitive, tedious, and long-running tasks. For instance, the mailbox backup script that I spoke about in the previous recipe, Displaying an interactive menu, took a long time to back up large mailboxes. Sometimes, staring at a terminal that seems to do nothing is unnerving—not to mention not knowing whether the script is actually doing something or not.

This is where writing progress comes into the picture. Here is the task: count 25 seconds and write progress for the percentage of time elapsed.

How to do it...

This is a percentage-based progress writing. Therefore, we need to know the total time beforehand. We will calculate the percentage...