Book Image

Windows PowerShell for .NET Developers - Second Edition

Book Image

Windows PowerShell for .NET Developers - Second Edition

Overview of this book

Windows PowerShell 5.0 for .NET Developers is your self-start guide to performing automation using Windows PowerShell. This book will help you to understand the PowerShell syntax and grammar and will also teach you techniques to remove the rough edges of manual deployments. Packed with PowerShell scripts and sample C# codes to automate tasks, it also includes real-world scenarios such as administrating office servers to help you save time and perform deployments swiftly and efficiently. The book begins with the Windows PowerShell basics, explores the significant features of Windows Management Framework 5.0, covers the basic concepts of Desired State Configuration and the importance of idempotent deployments. By the end of the book, you will have a good understanding of Windows PowerShell’s features and will be able to automate your tasks and manage configuration effectively.
Table of Contents (13 chapters)

Exploring JSON


JavaScript Object Notation (JSON) is a lightweight, text-based, open standard that is designed for data interchange. It is language-independent, with parsers available for Windows PowerShell.

The JSON format is often used to serialize and transmit structured data over a network connection. It is used primarily to transmit data between a server and a web application, as an alternative to XML.

You can use the following link to validate the JSON format:

http://jsonformatter.curiousconcept.com/

Here is a simple example of the JSON Format:

{
    "Title":  "Mr.",
    "Name":  "Scripting"
}

Windows PowerShell has two cmdlets: ConvertFrom-Json and ConvertTo-Json. Take a look at the following image:

As the name reads, it converts to and from. Let's take a look at how the following code works:

$json = @"
{
    "Title":  "Mr.",
    "Name":  "Scripting"
}
"@
$json | ConvertFrom-Json

Now, consider the following image:

The steps performed in the figure we just saw is explained as follows:

  • We...