Windows PowerShell Step by Step

[Pages:115]// Step by step Windows PowerShell

Third Edition

Ed Wilson

Intermediate

Windows PowerShell Step by Step, Third Edition

Ed Wilson

PUBLISHED BY Microsoft Press A division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399

Copyright ? 2015 by Ed Wilson

All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher.

Library of Congress Control Number: 2014922916 ISBN: 978-0-7356-7511-7

Printed and bound in the United States of America.

First Printing

Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Support at mspinput@. Please tell us what you think of this book at .

This book is provided "as-is" and expresses the author's views and opinions. The views, opinions and information expressed in this book, including URL and other Internet website references, may change without notice.

Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred.

Microsoft and the trademarks listed at on the "Trademarks" webpage are trademarks of the Microsoft group of companies. All other marks are property of their respective owners.

Acquisitions and Developmental Editor: Karen Szall Project Editor: Rosemary Caperton Editorial Production: Online Training Solutions, Inc. (OTSI) Technical Reviewer: Brian Wilhite; Technical Review services provided by Content Master, a member of CM Group, Ltd. Copyeditor: Kathy Krause (OTSI) Indexer: Susie Carr (OTSI) Cover: Twist Creative Seattle

To Teresa: you make life an adventure. --ED WILSON

Contents at a glance

CHAPTER 1 CHAPTER 2 CHAPTER 3 CHAPTER 4 CHAPTER 5 CHAPTER 6 CHAPTER 7 CHAPTER 8 CHAPTER 9 CHAPTER 10 CHAPTER 11 CHAPTER 12 CHAPTER 13 CHAPTER 14 CHAPTER 15 CHAPTER 16 CHAPTER 17 CHAPTER 18 CHAPTER 19 CHAPTER 20 CHAPTER 21 CHAPTER 22

Introduction

xix

Overview of Windows PowerShell 5.0

1

Using Windows PowerShell cmdlets

23

Understanding and using Windows PowerShell providers 65

Using Windows PowerShell remoting and jobs

109

Using Windows PowerShell scripts

137

Working with functions

179

Creating advanced functions and modules

217

Using the Windows PowerShell ISE

259

Working with Windows PowerShell profiles

275

Using WMI

291

Querying WMI

313

Remoting WMI

341

Calling WMI methods on WMI classes

361

Using the CIM cmdlets

375

Working with Active Directory

395

Working with the AD DS module

431

Deploying Active Directory by using Windows PowerShell 459

Debugging scripts

473

Handling errors

511

Using the Windows PowerShell workflow

547

Managing Windows PowerShell DSC

565

Using the PowerShell Gallery

581

Appendix A: Windows PowerShell scripting

best practices

591

Appendix B: Regular expressions quick reference

599

Index

603

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Chapter 1 Overview of Windows PowerShell 5.0

1

Understanding Windows PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Using cmdlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Installing Windows PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Deploying Windows PowerShell to down-level operating systems . . 3

Using command-line utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Security issues with Windows PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Controlling execution of Windows PowerShell cmdlets . . . . . . . . . . . 6 Confirming actions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Suspending confirmation of cmdlets . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Working with Windows PowerShell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Accessing Windows PowerShell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Configuring the Windows PowerShell console . . . . . . . . . . . . . . . . . . 11

Supplying options for cmdlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Working with the help options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

Exploring commands: Step-by-step exercises . . . . . . . . . . . . . . . . . . . . . . . . 19

Chapter 1 quick reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Chapter 2 Using Windows PowerShell cmdlets

23

Understanding the basics of cmdlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Using the Get-ChildItem cmdlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Obtaining a directory listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Formatting a directory listing by using the Format-List cmdlet . . . 26

What do you think of this book? We want to hear from you!

Microsoft is interested in hearing your feedback so we can improve our books and learning resources for you. To participate in a brief survey, please visit:



vii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download