0%

Book Description

Use PowerShell 6.0 on Linux to automate complex, repetitive, and time consuming tasks

About This Book

  • Understand PowerShell’s object-oriented approach, and truly cross-platform capabilities, which work equally well on Windows, Linux and macOS.
  • Extend your OMS capabilities to get rich insights about your Linux workloads to quickly remediate any issues.
  • A recipe-based guide that will enhance your native Linux capabilities with PowerShell 6.0.

Who This Book Is For

If you are system administrator who wants to learn to control and automate your Linux environment with PowerShell 6.0 then, this book is for you. Basic knowledge of PowerShell scripting would be necessary. Very basic knowledge required with respect to how an operating system is structured and how to use the command line interface to work with the operating system.

What You Will Learn

  • Understand the fundamentals of .NET Core and PowerShell
  • Understand the advanced concepts of .NET Core and PowerShell
  • Learn to write PowerShell scripts and functions with the best practices in mind
  • Take a deep dive into administering computers locally as well as remotely using PowerShell
  • Use PowerShell for advanced administration such as on the Cloud, Docker containers, VMware and SQL Server

In Detail

PowerShell is an implementation of .NET Core. .NET Core is a cross-platform open source management framework, which adheres to POSIX standards and makes available API calls that work well with all of the major operating systems: Windows, Linux and macOS. .NET Core for Linux has been a success, because of its adherence to standards, as well as for its lightweight implementation. PowerShell extends the capabilities towards management of Linux servers as well as using containerizers such as Docker.

This book will include real-world examples on how you can use core PowerShell functions to effectively administer Linux-based systems and environments. Later, this book will cover interesting recipes on how system administrators can make use of PowerShell 6.0 to quickly automate complex, repetitive and time-consuming tasks. This book will also teach you to develop scripts to automate tasks that involve systems and enterprise management. By the end of this book, you will also understand your OMS automation capabilities to apply, monitor, and update configurations, gaining real-time visibility into your Linux workloads to quickly get it resolved.

Style and approach

With a recipe-based approach, we will help you take advantage of PowerShell 6.0 to call all native Linux capabilities to automate your environment.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers
  2. Installation, Reference and Help
    1. Introduction
    2. Installing PowerShell
      1. Getting Ready
      2. How to do it...
        1. Installation on Ubuntu
          1. Installing from the repository
          2. Installing via direct download
        2. Installation on CentOS
          1. Installing from the repository
          2. Installing via direct download
        3. Using the AppImage package
      3. How it works...
      4. See also
    3. Fetching Help Information in PowerShell
    4. Fetching Help Information for a Specific Cmdlet
      1. How to do it...
      2. How it works...
      3. See also
    5. Updating Help
      1. How to do it...
      2. How it works...
    6. Searching Help for Keywords
      1. How to do it...
      2. How it works...
    7. Looking for help information specific to a parameter
      1. How to do it...
      2. How it works...
    8. Exploring the About_ Topics
      1. How to do it...
      2. How it works...
    9. Discovering Cmdlets
      1. How to do it...
      2. How it works...
    10. Finding Modules
      1. How to do it...
      2. How it works...
    11. Installing Modules from the Repository
      1. How to do it...
      2. How it works...
      3. See also
    12. Listing the Various Providers in PowerShell
      1. How to do it...
      2. How it works...
      3. See also
  3. Introducing the Core and its Capabilities
    1. Introduction
    2. Dissecting a .NET Core Object
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Breaking down an output into different objects
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Parsing input from text to object
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Comparing the outputs of Bash and PowerShell
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Comparing Windows PowerShell and PowerShell
      1. Support for snap-ins
      2. Convenience aliases
      3. PowerShell Workflows
      4. PowerShell Desired State Configuration
    7. Listing out the aliases and using them in place of cmdlets
      1. How to do it...
      2. How it works...
      3. See also
    8. Creating a Custom Alias
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    9. Export/Import Custom Aliases for Future Use
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    10. Listing out the execution policies and setting a suitable one
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
  4. Preparing for Administration using PowerShell
    1. Introduction
    2. Installing Visual Studio Code
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Configuring automatic variables
      1. Getting Ready
      2. How to do it...
      3. How it works...
    4. Changing the shell behaviour using a variable
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Enabling automated execution of commands for each load
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Customising the terminal prompt
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Understanding standard redirection in PowerShell
      1. How to do it...
      2. How it works...
        1. Out-File
        2. Tee-Object
        3. Accepting input from file
      3. There's more...
      4. See also
    8. Calling native Linux commands from PowerShell
      1. Getting started
      2. How to do it...
      3. How it works...
      4. See also
    9. Understanding cmdlets and parameters
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more
    10. Running cmdlets with minimal keystrokes
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
    11. Finding parameter aliases
      1. Getting Ready
      2. How to do it...
      3. How it works...
    12. Calling a PowerShell script
      1. Getting Ready
      2. How to do it...
      3. How it works...
    13. Dot-sourcing a PowerShell script
      1. How to do it...
      2. How it works...
      3. There's more...
    14. Calling a PowerShell cmdlet from outside of PowerShell
      1. How to do it...
      2. How it works...
    15. Recording the cmdlets run on the PowerShell console
      1. How to do it...
      2. How it works...
  5. First Steps in Administration using PowerShell
    1. Introduction
    2. Working with date properties
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Working with date and time functions
      1. How to do it...
      2. How it works...
    4. Working with currently-running processes to measure resource consumption
      1. How to do it...
      2. How it works...
    5. Launching and stopping a process
      1. Getting Ready
      2. How to do it...
      3. How it works...
    6. Finding the owner of a process
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    7. Invoking an application based on the file type
      1. How to do it...
      2. How it works...
    8. Installing the Crontab PowerShell module 
      1. How to do it...
      2. How it works...
    9. Scheduling jobs in PowerShell
      1. Getting Ready
      2. How to do it...
      3. How it works...
    10. Removing the jobs in PowerShell
      1. How to do it...
      2. How it works...
  6. Passing Data through the Pipeline
    1. Introduction
    2. Selecting columns from the output
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Limiting the number of output objects
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Expanding the properties within properties
      1. How to do it...
      2. How it works...
    5. Filtering objects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Grouping the output
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    7. Sorting the output
      1. How to do it...
      2. How it works...
    8. Taking actions on the returned objects
      1. Getting Ready
      2. How to do it...
      3. How it works...
    9. Understanding pipeline-enabled parameters
      1. How to do it...
      2. How it works...
    10. Importing content into PowerShell
      1. How to do it...
      2. How it works...
      3. See also
  7. Using Variables and Objects
    1. Introduction
    2. Using environment variables 
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    3. Storing the output of an instance of a .NET Core Object
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Adding custom properties to an object
      1. How to do it...
      2. How it works...
      3. See also
    5. Creating a custom object from a returned object
      1. How to do it...
      2. How it works...
      3. See also
    6. Understanding extension of Type Data
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Retaining object modifications across sessions
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    8. Removing custom type data
      1. How to do it...
      2. How it works...
      3. See also
  8. Flow Control using Branches and Loops
    1. Introduction
    2. Using If–ElseIf–Else conditions to control script flow
      1. Getting Ready
      2. How to do it...
      3. How it works...
    3. Using Switch–Case conditions to control script flow
      1. How to do it...
      2. How it works...
    4. Learning to use delays
      1. How to do it...
      2. How it works...
    5. Writing a basic looping construct
      1. How to do it
      2. How it works...
    6. Writing a more complex loop on a predefined array
      1. How to do it...
      2. How it works...
    7. Using the For loop construct
      1. How to do it...
      2. How it works...
    8. Using the While loop construct
      1. How to do it
      2. How it works...
    9. Cleaning empty directories using the Do–While construct
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    10. Cleaning empty directories using the Do–Until construct
      1. How to do it...
      2. How it works...
  9. Working with Strings
  10. Performing Calculations
    1. Technical Requirements
    2. Introduction
    3. Performing arithmetic operations
      1. Getting Ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Performing calculations on the output
      1. Getting ready
      2. How to do it
      3. How it works
      4. There's more
    5. Working with Administrative Constants
      1. Getting ready
      2. How to do it
      3. How it works
    6. Working with calculated properties
      1. Getting ready
      2. How to do it
      3. How it works
    7. Working with binary numbers
      1. How to do it
      2. How it works
    8. Performing base conversion
      1. How to do it
      2. How it works
      3. There's more
  11. Using Arrays and Hash Tables
  12. Handling Files and Directories
  13. Building Scripts and Functions
  14. Advanced Concepts of Functions
  15. Getting Under the Hood: Debugging and Error Handling
  16. Working with the Environment
  17. Security in PowerShell
  18. Enterprise Administration using PowerShell
  19. Best Practices Round-up
  20. PowerShell and Cloud Operations
  21. Using PowerShell for SQL Database Management
3.141.31.240