Mastering Windows PowerShell Scripting
eBook - ePub

Mastering Windows PowerShell Scripting

Automate and manage your environment using PowerShell Core 6.0, 3rd Edition

Chris Dent

  1. 626 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Mastering Windows PowerShell Scripting

Automate and manage your environment using PowerShell Core 6.0, 3rd Edition

Chris Dent

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Grasp advanced PowerShell Core 6.0 functionalities to automate your environment

Key Features

  • Keep up with changes introduced in PowerShell Core 6.0
  • Easily maintain appropriate compatibility with older versions
  • Automate complex tasks, manipulate data, and secure your environment with PowerShell Core 6.0

Book Description

PowerShell scripts offer a handy way to automate various chores, however working effectively with these scripts can be a difficult task.This comprehensive guide starts with the fundamentals before moving on to advanced-level topics to help you become a PowerShell Core 6.0 expert. The first module, PowerShell Core 6.0 Fundamentals, begins with the new features of PowerShell Core 6.0, installing it on Linux, and working with parameters, objects and.NET classes from within PowerShell Core 6.0. As you make your way through the chapters, you'll see how to efficiently manage large amounts of data and interact with other services using PowerShell Core 6.0. You'll be able to make the most of PowerShell Core 6.0's powerful automation feature, where you will have different methods available to parse data and manipulate regular expressions and Windows Management Instrumentation (WMI). After having explored automation, you will enter the extending PowerShell Core 6.0 module, covering asynchronous processing and desired state configuration. In the last module, you will learn to extend PowerShell Core 6.0 using advanced scripts and filters, and also debug issues along with working on error handling techniques.By the end of this book, you will be an expert in scripting with PowerShell Core 6.0.

What you will learn

  • Optimize code through the use of functions, switches, and looping structures
  • Work with objects and operators to test and manipulate data
  • Parse and manipulate different data types
  • Create scripts and functions using PowerShell
  • Use jobs, events, and popular public modules which assist with implementing multithreading
  • Write.NET classes with ease within the PowerShell
  • Create and implement regular expressions in PowerShell scripts
  • Make use of advanced techniques to define and restrict the behavior of parameters

Who this book is for

If you are a system administrator who wants to become an expert in controlling and automating your Windows environment, then Mastering Windows PowerShell Scripting is for you. It is also ideal for those new to the PowerShell language.

]]>

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Mastering Windows PowerShell Scripting est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Mastering Windows PowerShell Scripting par Chris Dent en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Computer Science General. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2019
ISBN
9781789533989

Section 1: Exploring PowerShell Fundamentals

In this section, we will explore the basics of the PowerShell language.
The following chapters are included in this section:
  • Chapter 1, Introduction to PowerShell
  • Chapter 2, Modules and Snap-ins
  • Chapter 3, Working with Objects in PowerShell
  • Chapter 4, Operators

Introduction to PowerShell

PowerShell has reached a point where it has split into Windows PowerShell and PowerShell Core. Windows PowerShell accounts for versions up to, and including, PowerShell 5.1. Windows PowerShell is based on the .NET full framework. PowerShell Core accounts for version 6 and over and is based on the .NET core framework.
The future of PowerShell is in PowerShell Core; it opens up cross-platform scripting with PowerShell, that is, support for Linux and macOS.
As well as the change to .NET, there are an increasing number of differences between Windows PowerShell and PowerShell Core that must be accounted for.
The differences between Windows PowerShell and PowerShell Core will be highlighted throughout this book.
This book is split into a number of sections. Much of this book is intended to act as a reference. We will cover the following topics in this book:
  • Exploring PowerShell fundamentals
  • Working with data
  • Automating with PowerShell
  • Extending PowerShell
In the first section of this book, while exploring the PowerShell fundamentals, we will look at the use of language and cover as many building blocks as possible.
In this chapter, we will briefly look at a number of short, diverse topics:
  • What is PowerShell?
  • PowerShell editors
  • Getting help
  • Command naming
  • Command discovery
  • Parameters and parameter sets
  • Introduction to providers
  • Introduction to splatting

Technical requirements

This chapter makes use of the following on the Windows platform:
  • Windows PowerShell 5
  • PowerShell Core 6.1

What is PowerShell?

PowerShell is a mixture of a command line, a functional programming language, and an object-oriented programming language. PowerShell is based on Microsoft .NET, which gives it a level of open flexibility that was not available in Microsoft's scripting languages (such as VBScript or batch) before this.
PowerShell is an explorer's scripting language. With built-in help, command discovery, and with access to much of the .NET framework, it is possible to dig down through the layers.
This book is based on PowerShell Core 6.1 with references to PowerShell 5.1; some of the features that are discussed in this book may not be available in the earlier versions of PowerShell.
PowerShell Core may be installed side by side with Windows PowerShell. Preview versions of PowerShell Core can often be installed side by side with full releases of PowerShell Core.

PowerShell editors

While it is possible to write for PowerShell using the notepad application alone, it is rarely desirable. Using an editor that was designed to work with PowerShell can save a lot of time.
Specialized PowerShell editors such as Visual Studio Code (VS Code), PowerShell Studio, and PowerShell ISE offer automatic completion (IntelliSense), which reduces the amount of cross-referencing required while writing code. Finding a comfortable editor early on is a good way to ease into PowerShell; memorizing commands and parameters is not necessary.
PowerShell ISE is not planned to be released to support PowerShell 6 at this time. VS Code is the most commonly recommended editor for PowerShell. VS Code is a free open source editor that was published by Microsoft VS Code and may be downloaded from http://code.visualstudio.com.
The PowerShell extension should be installed, and other extensions may be found on the marketplace: https://marketplace.visualstudio.com/VSCode.
VS Code provides support for PowerShell Core; the following screenshot shows how to change the version of PowerShell that's used when editing a script:

Getting help

Gaining confidence using the built-in help system is an important part of working with PowerShell. In PowerShell, help is extensive; authors can easily write their own help content when working with functions, scripts, and script modules.
A number of commands are available to interact with the help system, as follows:
  • Get-Help
  • Save-Help
  • Update-Help
Before exploring these commands, the concept of Updatable help should be discussed, as help may not be present on a system after installation.

Updatable help

Updatable help was introduced with PowerShell 3. It gives authors the option to store the most recent versions of their help documentation outside of PowerShell on web servers.
Which modules support updatable help?

A list of modules that support updatable help may be viewed by running the following command: Get-Module -ListAvailable | Where-Object HelpInfoURI -like *.
Help for the core components of PowerShell is no longer a part of the Windows Management Framework package and must be downloaded before it can be viewed. The first time Get-Help is run, you will be prompted to update help.
If the previous prompt is accepted, PowerShell will attempt to download content for any module that supports updatable help.
Computers with no internet access or computers behind a restrictive proxy server may not be able to download the help content directly. The Save-Help command, which will be discussed later in this section, may be used to work around this problem. If PowerShell is unable to download help, it can only show a small amount of information about a command; for example, without downloading help, the content for the Out-Null command is minimal, as shown here:
PS> Get-Help Out-Null

NAME
Out-Null

SYNTAX
Out-Null [-InputObject <psobject>] [<CommonParameters>]


ALIASES
None


REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer.
It is displaying only partial help.
-- To download and i...

Table des matiĂšres