Book Image

Mastering PowerShell Scripting - Fourth Edition

By : Chris Dent
5 (1)
Book Image

Mastering PowerShell Scripting - Fourth Edition

5 (1)
By: Chris Dent

Overview of this book

PowerShell scripts offer a convenient way to automate various tasks, but working with them can be daunting. Mastering PowerShell Scripting takes away the fear and helps you navigate through PowerShell's capabilities.This extensively revised edition includes new chapters on debugging and troubleshooting and creating GUIs (online chapter). Learn the new features of PowerShell 7.1 by working with parameters, objects, and .NET classes from within PowerShell 7.1. This comprehensive guide starts with the basics before moving on to advanced topics, including asynchronous processing, desired state configuration, using more complex scripts and filters, debugging issues, and error-handling techniques. Explore how to efficiently manage substantial amounts of data and interact with other services using PowerShell 7.1. This book will help you to make the most of PowerShell's automation features, using different methods to parse data, manipulate regular expressions, and work with Windows Management Instrumentation (WMI).
Table of Contents (26 chapters)
24
Other Books You May Enjoy
25
Index

XML commands

Extensible Markup Language (XML) is a plain text format that is used to store structured data. XML is written to be both human and machine readable.

PowerShell includes Select-Xml and ConvertTo-Xml commands to work with XML content.

Before exploring the commands, let's look at the basic structure of XML documents.

About XML

XML documents often begin with a declaration, as shown here:

<?xml version="1.0" encoding="utf-8"?>

This declaration has three possible attributes. The version attribute is mandatory when a declaration is included:

  • version: The XML version, 1.0 or 1.1
  • encoding: The file encoding, most frequently utf-8 or utf-16
  • standalone: Whether the XML file uses an internal or external Document Type Definition (DTD); permissible values are yes or no

The use of the standalone directive with DTD is beyond the scope of this chapter.

Elements and attributes

XML is similar...