Book Image

Instant Windows PowerShell Guide

By : Harshul Patel
Book Image

Instant Windows PowerShell Guide

By: Harshul Patel

Overview of this book

Windows PowerShell has become a booming scripting language over the last couple of years. It has extensive support with an ample number of vendor products, providing a standardized platform for automation and administration. It has massive support for all Microsoft products which creates a layer that can easily automate everything. In the latest version, the PowerShell team has introduced much more functionality with thousands of CMDLETs, part of various modules.This book is a quick reference guide to enable you to get the most out of the latest Windows PowerShell techniques. In this book, you will find new enhancements in the latest version of PowerShell with some helpful examples. This book enables you to quickly move from older versions of PowerShell to Version 3.0 and Version 4.0.This practical, example-oriented book helps you to overcome the difficulty of using and discovering CMDLETs by providing precise information about everything that has been newly introduced in the latest version of Windows PowerShell. It also focuses on the new configuration management system with the help of DSC as a new feature of Windows PowerShell v4.0.You will learn how to use the newly introduced CMDLETs and parameters to perform daily routine tasks. You will also learn how to administer the servers remotely and maintain persistent sessions to provide continuity. You will gain an insight into writing efficient scripts by using various parameters, snippets, and workflows to gain more productivity. You will also be introduced to various modules like CimCmdlets, PSScheduledJob, PSDesiredStateConfiguration, and so on in order to enhance your scripts with the latest instrumentation. Finally this book will make you aware of the capabilities of PowerShell v4.0 and how to fully leverage the functionality introduced in the new version.
Table of Contents (7 chapters)

Windows PowerShell – prerequisites


In the last few years, the scripting world has witnessed a number of changes. We can hardly recall the time when people used ancient mainframe machines with green-colored text and a black screen background. But now, times have changed and we are, in fact, living in a world where technology adoption is quicker than ever.

Now, an ample number of scripting languages exist that can fulfill the needs of an administrator. One of the questions that arise in one's mind is: Why should I go with Windows PowerShell?

There are certain reasons why we prefer Windows PowerShell over other scripting languages. I have intentionally included this short note at the beginning of this book to give you a clear understanding of this scripting language.

For example, there are strong scripting languages, such as VBScript, Ruby, Python, and Perl, which administrators have adopted as well. VBScript became popular because of the automation of routine local administrator tasks, but the code was a bit complex and hard to understand for novice users. Looking at Windows PowerShell, I feel the Microsoft team has worked hard and gifted us a powerful, interactive scripting shell with an object-driven approach.

The important and exciting thing about this language is its object-based output, which can be easily reused. It has "pipeline" and "PSRemoting" as its crucial features, which puts this language as the first priority in comparison with other scripting languages.

So far, we have had four stable versions available for Windows PowerShell. Windows PowerShell v1.0 was an extension of the command prompt, but with a limited number of commands. In Version 2, the team introduced the pipeline and PSRemoting concepts, which made Windows PowerShell a popular scripting shell. Furthermore, with the release of Windows Server 2012 and Windows 8, they have drastically improved with Windows PowerShell Version 3.0 in terms of the number of CMDLETs and built-in modules. They have also introduced Windows PowerShell Web Access (PWA), PowerShell workflows, and Scheduled Jobs concepts in this version. The exciting part is that, while we are in the process of publishing this book, the Microsoft team is working on the next release of its operating systems named Windows Server 2012 R2 and Windows 8.1. In the next release, they have Windows PowerShell v4.0 embedded with extensive functionality, for example, Desired State Configuration (DSC) and so on.

In this book, we have mostly covered new CMDLETs, which were introduced in v3.0 and v4.0. Also, we will draft some functionality changes that exist in the latest versions of Windows PowerShell.

Requirements for Windows Management Framework 3.0and Windows Management Framework 4.0

Let us see what Windows Management Framework 3.0 requires.

By default, Windows PowerShell 3.0 comes with Windows Server 2012 and Windows 8. There are a number of default modules present in this version. If you are running an operating system lower than the one specified, you need to manually install Windows Management Framework 3.0 (WMF 3.0). If you have installed any previous releases of Windows Management Framework, you must uninstall them before installing Windows Management Framework 3.0.

Windows Management Framework 3.0 can be installed only on the following operating system versions:

  • Windows 7 SP1

  • Windows Server 2008 R2 SP1 (It also works with the server core installation)

  • Windows Server 2008 SP2

Windows Management Framework 3.0 requires the following software to be installed prior to installing WMF 3.0:

Now, let us see what Windows Management Framework 4.0 requires.

By default, Windows PowerShell 4.0 comes up with Windows Server 2012 R2 and Windows 8.1. If you are running an operating system lower than the one specified earlier, you need to manually install Windows Management Framework 4.0 (WMF 4.0). If you have installed any previous releases of Windows Management Framework, you must uninstall them before installing Windows Management Framework 4.0.

Windows Management Framework 4.0 can be installed only on the following operating system versions:

  • Windows 7 SP1

  • Windows Server 2012

  • Windows Server 2008 R2 SP1 (It also works with the Server Core installation)

Windows Management Framework 4.0 requires the following software to be installed prior to installing WMF 4.0:

Package contents

The following is information about the contents of WMF 3.0 and WMF 4.0.

  • Windows Management Framework 3.0: It is available for all supported versions of Windows for the following languages: English, Chinese (simplified), Chinese (traditional), French, German, Italian, Japanese, Korean, Portuguese (Brazil), Russian, and Spanish. Windows Management Framework 3.0 contains:

    • Windows PowerShell 3.0

    • Windows Remote Management (WinRM) 3.0

    • Windows Management Instrumentation (WMI)

    • Management OData IIS Extensions

    • Server Manager CIM Provider

  • Windows Management Framework 4.0: It contains:

    • Windows PowerShell

    • Windows PowerShell ISE

    • Windows PowerShell web services (Management OData IIS Extensions)

    • Windows Remote Management (WinRM)

    • Windows Management Instrumentation (WMI)

    WMF 4.0 includes a new feature—Windows PowerShell Desired State Configuration (DSC)

Additionally, the following requirements should also be met:

  • To install Windows PowerShell Integrated Scripting Environment (ISE) for Windows PowerShell 3.0 on computers running Windows Server 2008 R2 with Service Pack 1, before installing WMF 3.0, use Server Manager to add the optional Windows PowerShell ISE feature to Windows PowerShell

  • Install the latest updates before installing WMF 3.0 or WMF 4.0