Microsoft Exchange Server PowerShell Essentials - Biswanath Banerjee - E-Book

Microsoft Exchange Server PowerShell Essentials E-Book

Biswanath Banerjee

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Leverage the power of basic Windows PowerShell scripts to manage your Exchange messaging environment

About This Book

  • Get to grips with Windows PowerShell and how it can be used to manage various aspects of the operating system and applications
  • Become proficient in PowerShell and apply it to manage Exchange infrastructure on-premise or via Exchange Online as part of Office 365
  • Learn to create Windows PowerShell scripts to do administrative tasks with this step-by-step, easy-to-follow guide

Who This Book Is For

This book is for administrators with a basic or limited understanding of Windows PowerShell and who want to increase their skill set in managing both the Exchange On Premise and Online environments.

What You Will Learn

  • Deep dive into the Windows PowerShell basics
  • Create and manage Recipients and permissions
  • Manage Distribution Group members, permissions, and group types
  • Understand Certificates and Role-Based Access Control using real-world examples
  • Review the usage of email address, address book, and retention policies with examples
  • Learn to manage Exchange Client Access and Mailbox Server roles
  • Use PowerShell for auditing and risk management in your Exchange organization
  • Manage a highly available Exchange environment using PowerShell
  • Interact with Exchange through the use of the Exchange Web Services-managed API

In Detail

PowerShell has become one of the most important skills in an Exchange administrator's armory. PowerShell has proved its mettle so widely that, if you're not already starting to learn PowerShell, then you're falling behind the industry. It isn't difficult to learn PowerShell at all. In fact, if you've ever run commands from a CMD prompt, then you'll be able to start using PowerShell straightaway.

This book will walk you through the essentials of PowerShell in Microsoft Exchange Server and make sure you understand its nitty gritty effectively.

You will first walk through the core concepts of PowerShell and their applications. This book discusses ways to automate tasks and activities that are performed by Exchange administrators and that otherwise take a lot of manual effort.

Microsoft Exchange PowerShell Essentials will provide all the required details for Active Directory, System, and Exchange administrators to help them understand Windows PowerShell and build the required scripts to manage the Exchange Infrastructure.

Style and approach

This book is written with its target audience in mind; concepts are explained and followed by real-life examples. A comprehensive script is provided in each chapter to give you hands-on practice with all the major commands used in it.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 235

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Microsoft Exchange Server PowerShell Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Instant updates on new Packt books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with PowerShell
Introducing Windows PowerShell
Understanding PowerShell syntax
Understanding the help system
The Help parameter (?)
The Get-Help cmdlet
Understanding Logging and Transcripts
Using variables
Assignment operators
Comparison operators
Using pipelines
Using loops
The Do loop
ForEach loops
While loops
Using arrays
Retrieving values from an array
Using filters and exporting data
Using If statements
Switch statements
Writing a basic script
Summary
2. Learning Recipient Management
Managing users
Creating a Mailbox for a new user
Creating a new user in Active Directory and a new mailbox for the user
Enabling mailbox for an existing user in Active directory
Managing permissions
Manage Full Access permissions
Manage Send As permission
Manage Send On Behalf permission
Managing folder/calendar permission
Managing room mailboxes
Import export of objects
Import user accounts in bulk using a CSV file
Import external contacts in bulk using a CSV file
Exporting objects to a CSV file
Connecting from Remote computers
Connecting to a remote Exchange 2013/2016 Server
Connecting to Exchange online
Troubleshooting Remote PowerShell session connectivity
Mailbox reporting
Automation with scripting agents
Scenario 1
Scenario 2
Writing a basic script
Scheduling your task
Summary
3. Handling Distribution Groups
Introducing distribution groups
Managing distribution groups
Distribution Group naming policy
Creating Distribution Groups
Changing Distribution Group properties
Managing distribution group permissions
Scenario
Managing distribution group members
Converting group types
Automation with dynamic Distribution groups
Dynamic Distribution group properties
Writing an advance script
Summary
4. Exchange Security
Components of Role Based Access Control
Managing Role Based Access Control
Where (scope)
What (role)
Who (Role Group)
Role assignment
Managing exchange certificates
Types of Certificates
Steps to manage certificates
Step 1 – generating a certificate
Step 2 – importing the certificate
Step 3 – assigning services to the new certificate
Managing Application Relaying emails
Managing External access of Exchange Admin Center
Writing a basic script
Summary
5. Everything about Microsoft Exchange Policies
Introducing Exchange Policies
Creating and managing E-mail Address Policies
Creating and managing Address Book policies
Creating and managing Retention Policies
Writing a basic script
Summary
6. Handling Exchange Server Roles
Configuring POP, IMAP, ActiveSync, and Outlook Anywhere
Configuring ActiveSync
Configuring Outlook Anywhere
Managing Client Access Servers
Managing transport connectors
Send connector
Receive connector
Managing DSN Messages
Managing Message tracking logs
Managing transport queues
Examples
Managing Public Folder Mailboxes
Writing a basic script
Summary
7. Auditing and E-Discovery
New features in Exchange 2016
The In-Place hold
Retrieving and exporting e-mails for Auditing using In-Place E-discovery
Retrieving content using KQL queries
Searching and removing e-mails from the server
Enable Auditing and understanding its usage
Administrator audit logs
Mailbox audit logs
Writing a basic script
Summary
8. Managing High Availability
Managing Database Availability Groups
DAG Quorum model
Creating DAG and adding/removing members
DAG networks
Adding/removing Database copies
Managing Database Copies
Suspending/resuming Database copies
Database Seeding
Retrieving and setting Database configuration
Controlling high availability failover mechanisms
Database Availability Group health checks
Database Availability Group Maintenance tasks
Writing a basic script
Summary
9. Exploring EWS Managed API
Introducing Exchange Web Services
Understanding the EWS managed API
Writing basic EWS managed API code
Creating custom folders in Mailboxes
Writing a basic script
Summary
10. Common Administration Tasks
Managing Active Sync devices
Managing Databases
Managing Transport rules and adding disclaimers
Managing Non-Delivery Reports
Managing Active Directory Attributes
Removing old log files
Health check commands
Test-ActiveSyncConnectivity
Test-ReplicationHealth
Test-OutlookWebServices
Get-Server Health
Summary
Index

Microsoft Exchange Server PowerShell Essentials

Microsoft Exchange Server PowerShell Essentials

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: February 2016

Production reference: 1190216

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78217-603-9

www.packtpub.com

Credits

Author

Biswanath Banerjee

Reviewer

Mark Andrews

Commissioning Editor

Taron Pereira

Acquisition Editor

Manish Nainani

Content Development Editor

Kajal Thapar

Technical Editor

Gebin George

Copy Editor

Yesha Gangani

Project Coordinator

Dinesh Rathe

Proofreader

Safis Editing

Indexer

Rekha Nair

Production Coordinator

Melwyn Dsa

Cover Work

Melwyn Dsa

About the Author

Biswanath Banerjee has been working with Exchange Servers since 2005 in various roles in support, training, and consulting. Spanning an IT career of over 14 years, he has worked on multiple Active Directory and Exchange migration projects. He specializes in Planning and Deployment of Microsoft Infrastructure Solutions such as Active Directory, Exchange, Lync, Skype for Business, and various Office 365 services.

About the Reviewer

Mark Andrews career in technology has been a varied one. Over the last 18 years, he has held several different positions ranging from customer service to quality assurance. Throughout all of these positions, the responsibility of configuration management and build management has always fallen either to Mark personally or to one of the groups that he managed; because of his "keeping a hand in" management style, he has been involved closely with the scripting and automation framework for this area. Creating scripted frameworks that intercommunicate across machine/operating system/domain boundaries is a passion for him.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Instant updates on new Packt books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter or the Packt Enterprise Facebook page.

Preface

PowerShell has become one of the most important skills in an Exchange administrator's armory. PowerShell has proved its mettle so widely that, if you're not already starting to learn PowerShell, then you're falling behind the industry. It isn't difficult to learn PowerShell at all. In fact, if you've ever run commands from a CMD prompt, then you'll be able to start using PowerShell straight away.

This book will walk you through the essentials of PowerShell in Microsoft Exchange Server, and make sure you understand its nitty gritty effectively. There are a lot of examples and scripts that will demonstrate how you can use PowerShell to be more effective and save time as an administrator, which otherwise would have been spent performing repetitive tasks.

Microsoft Exchange PowerShell Essentials will provide all the required details for Active Directory, System, and Exchange administrators to help them understand Windows PowerShell and build the required scripts to manage the Exchange Infrastructure.

What this book covers

Chapter 1, Getting Started with PowerShell, provides an introduction to Windows PowerShell, which will build a strong foundation for the latter chapters.

Chapter 2, Learning Recipient Management, teaches you ways to manage recipients in an Exchange organization.

Chapter 3, Handling Distribution Groups, is about managing different distribution groups as it plays a major role in the Exchange Administration.

Chapter 4, Exchange Security, talks about securing Exchange and delegating access to administration tasks using Role-Based Access Control.

Chapter 5, Everything about Microsoft Exchange Policies, covers how to manage address books, email addresses, and Retention Policies in Exchange 2013 and Exchange 2016.

Chapter 6, Handling Exchange Server Roles, talks about configuring Exchange Client Access such as POP, IMAP, Outlook Anywhere, ActiveSync, and different Transport Services.

Chapter 7, Auditing and E-Discovery, reviews auditing and discovery features in Exchange that will help Organizations meet their Compliance and e-discovery requirements.

Chapter 8, Managing High Availability, uses our knowledge of PowerShell to manage high availability for Exchange 2013 and 2016 Organization.

Chapter 9, Exploring EWS Managed API, reviews Exchange Web Services application programming interface (API) and its usage in managing an Exchange On Premise and Online Organization.

Chapter 10, Common Administration Tasks, reviews some of the common administrative tasks in Exchange and uses PowerShell to save time and effort spent in performing repetitive jobs.

What you need for this book

The following is a list of softwares and supported operating systems required for this book:

Software required Exchange Server 2013 or 2016OS required—Windows 2008 R2, Windows 2012, or Windows 2012 R2Hardware Required:

Component

Requirement

Processor

x64 architecture-based computer with Intel processor that supports Intel 64 architecture (formerly known as Intel EM64T)AMD processor that supports the AMD64 platformIntel Itanium IA64 processors not supported

Memory

Varies depending on Exchange roles that are installed:

Mailbox 8GB minimumEdge Transport 4GB minimum

Paging file size

The minimum of page file size must be set to physical RAM plus 10 MB, to a maximum size of 32778 MB if you're using more than 32GB of RAM.

Disk space

At least 30 GB on the drive on which you install ExchangeAn additional 500 MB of available disk space for each Unified Messaging (UM) language pack that you plan to install200 MB of available disk space on the system driveA hard disk that stores the message queue database on with at least 500 MB of free space

Drive

DVD-ROM drive, local, or network accessible

Screen resolution

1024 x 768 pixels or higher

To view complete system requirements of Exchange Server 2016, you can log on to https://technet.microsoft.com/en-us/library/aa996719(v=exchg.160).aspx.

Who this book is for

This book is for administrators with a basic or limited understanding of Windows PowerShell and who want to increase their skill set in managing both the Exchange On Premise and Online environments.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MicrosoftExchangeServerPowerShellEssentials_ColoredImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Getting Started with PowerShell

This chapter will provide introduction to Windows PowerShell that is required for the rest of the chapters of this book. You will learn about the usage of Windows PowerShell cmdlets, variables, arrays, and loops. You will also learn the use of the PowerShell Help system. We will cover the concept of filtering and exporting objects using pipelines and the usage of loops and conditional statements. This chapter will create a foundation, and we will use subsequent chapters to build this foundation.

The following topics will be discussed in this chapter:

Introducing Windows PowerShellUnderstanding PowerShell syntaxUnderstanding the help systemUnderstanding logging and transcriptsUsing variablesUsing pipelinesUsing loopingUsing arraysUsing filters and exporting dataUsing If statementsWriting a basic script

Introducing Windows PowerShell

Windows PowerShell is the evolution of the Windows command-line shell, which provides a scripting environment for MS-DOS and the Windows operating system. In MS-DOS and Windows 9X, the shell was command.com, and it was cmd.exe for Windows NT family of the operating system. In the UNIX world, there are different shells such as SH, KSH, CSH, and BASH.

Almost all of these shells provide an environment to execute a command or utility and present the output as text. These shells have some built-in commands such as dir in cmd.exe in Windows NT or later versions, but these built-in commands are limited; and hence, new utilities are written to fill the gap. Shells supported the use of a scripting language (batch files) to automate tasks. There were limitations when it came to creating complex scripts and automating all other aspects provided by a Graphical User Interface (GUI) as equivalent commands are not exposed and the scripting language was basic.

Windows scripting host (Wscript.exe) and its command-line counterpart called Cscript.exe was introduced in 1998 with the release of Windows 98 to address some of the challenges. It is a language-independent scripting environment and allows scripts written in Jscript and VBScript using the APIs exposed by applications. There were deficiencies in this scripting environment due to limited documentation and interoperability issues with shell and security vulnerabilities. There were several security breaches as computer viruses exploited features provided by WSH. There were a few other attempts made by Microsoft to build utilities for specific purpose—for example, netsh—with their list of supported command sets, but they were not integrated with the shell and were inoperable.

In 2005, Microsoft released a new shell called Monad (also known as Microsoft Shell(MSH)), which is designed to automate a wide range of administrative tasks and is based on a new design as opposed to its predecessors.

Similar to the command.com and cmd.exe shells, Windows PowerShell can run three types of programs: built-in commands, external programs, and scripts. However, unlike a command shell, the built-in commands are not embedded into the shell environment but are available as modules in one or more .DLL files. This allows both Microsoft and vendors to write custom modules to manage their applications using PowerShell. Now, most of Microsoft and vendor's applications support management through Windows PowerShell, for example, Windows Server, Exchange Server, SharePoint, Lync Server/Skype for business, and VMWare.

Windows PowerShell is different than its predecessors in the following ways:

Windows PowerShell processes objects instead of text that are based on the .Net framework and provide lots of built-in commandsAll commands use the same command parser instead of different parser for each utility, which makes the use of PowerShell consistent and easier as compared to the earlier shell environmentsAdministrators can still use the tools and utilities that they are used to in Windows PowerShell such as Net, SC, and Reg.exeAs PowerShell is based on the .NET framework, one can write their own cmdlets using Microsoft Visual Studio and languages supported by the Common Language Runtime (CLR) such as C#

With the release of PowerShell 2.0, some APIs (application programming interface) were released that could be used to invoke PowerShell commands right from within your applications. Applications can then use certain PowerShell commands to perform a specific operation, which earlier could only be performed by GUI.

Starting from Exchange Server 2007, this capability has been used to its best advantage as will be explained over the course of the book. Learning PowerShell will help you in managing Microsoft, vendor applications, and services that support PowerShell. It will provide you the skillset required to manage and automate different aspects of Microsoft cloud-based offerings such as Office 365 and Windows Azure. Both of these support PowerShell and have specific modules for management. However, our focus in this book will be on managing Exchange through Windows PowerShell. At times, GUI is strictly used for illustration.

If you are interested in a .Net development, you can write your own cmdlet (pronounced as command-lets) in PowerShell that will perform a specific operation. For this, you will need PowerShell 2.0 Software Development Kit (SDK) and Visual Studio Express Edition. Both of these are free downloads.

Tip

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The following table summarizes the history of the different versions of Windows PowerShell:

Version

Year released

Operating systems

Features

1

2006

Windows Server 2003, Windows Server 2008, Windows XP SP2, and Windows Vista

First release

2

2009

Windows XP SP3, Windows Server 2003 SP2, Windows Vista SP1, Windows Server 2008 R2, and Windows 7

Remoting, Eventing, jobs, modules, ISE, and Exception handling

3

2012

Windows Server 2012 and Windows 8

Session connectivity, Scheduled jobs, update-help, and resumable sessions

4

2013

Windows Server 2012 R2, Windows 8.1, Windows 7 SP1, Windows Server 2008 R2 SP1, and Windows Server 2012

Desired State Configuration, Enhanced debugging, exportable help, and network diagnostics

5.0

2015

In Public Preview at the time of writing this book

OneGet, PowerShellGet, class definitions, and switch management improvements

Understanding PowerShell syntax

Windows PowerShell uses a verb-noun pair as a naming system. The name of each cmdlet includes a standard verb hyphenated with a specific noun. Verbs are used for specific actions in Windows PowerShell, and nouns are used to describe objects by users and system administrators. Here are some of the examples that show how little effort is required to work with cmdlets, and one does not have to memorize them.

Nouns in a cmdlet describe what the cmdlet will act on. For example, get-process, get-service, stop-process and stop-service. If this is used regularly, one can get to know the standard set of verbs and nouns used in PowerShell. With these verb-noun pair, hundreds of cmdlet names can be remembered and used.

You will be able to recognize the operation performed by a cmdlet by just reading the name as it is mostly apparent about the name used by a new command should relate to the operation. For example, get-computer will give you a list of computers on your network. Get-date and get-time will display the system date and time respectively. Similarly, stop-computer will shut down a computer. Set-date and set-time will set the system's date and time.

Let's look at how to list all the commands that have the particular verbs called Get and Set using Get-command with the –verb parameter. The output of this command is piped to display in a table format (more on this will be covered later in the Usage of pipelines section).

In the next example, we will just use instead of a format table:

Now, let's use the -Noun parameter, and we will find a list of commands that affect the same object type. For example, if you want to see commands that are available for managing computers, type the following command:

Traditionally, the commands in the earlier shells usually do not have a consistent parameter name. Sometimes, they don't have a name at all, and even if they do, they are abbreviated to make typing easier. But, this makes it difficult for new users to understand the parameters that are used. In Windows PowerShell, consistency is encouraged by using developer guidance on the usage of parameter names.

The names of the parameters in Windows PowerShell have a hyphen '-' prepended to them to allow PowerShell to demarcate them as parameters. In the get-command –Noun example, the name of the parameter is Noun and is typed as –Noun.

The cmdlets in Windows PowerShell support several common parameters as the PowerShell engine controls these parameters. So, no matter how they are implemented, they will behave in a similar way. Another way to drive the consistency and learning of Windows PowerShell are some of the common parameters like—Confirm, WhatIf, outvariable, warningaction, warningvariable, debug, and verbose.

Understanding the help system

This section will cover the use of help in Windows PowerShell. The help topic for a particular command or conceptual help can assist an administrator who is new to Windows PowerShell or using a particular set of cmdlets to understand its syntax and usage.

The Help parameter (?)

The -? parameter with a cmdlet will display Windows PowerShell help for the cmdlet:

The Get-Help cmdlet

The Get-Help cmdlet displays help information about PowerShell cmdlets. Some of the examples are discussed as follows.

The following example gives you the help files from the PowerShell help system one page at a time:

PS C:\>get-help * | more

If you know the alias of the cmdlet you are trying to get help for, use the —detailed parameter for full help:

PS C:\>get-help gps -detailed

If you are not sure of the exact parameter but remember the initial letter, use the following to get help:

PS C:\>get-help get-process -parameter i*

This lists all the parameters of the cmdlet get-process:

PS C:\>get-help get-process -Parameter *

This provides help with the syntax of the select-object cmdlet:

PS C:\>(get-help select-object).syntax

There are other properties of the help object such as input types, module name, examples, and more. If you are looking to find all the properties and methods of help object type called get-help <cmdlet-name> | get-member, for example, PS C:\> get-help get-Service | get-member.

Understanding Logging and Transcripts

The transcript feature in PowerShell helps you to record all your cmdlets and activities at the prompt. This feature is not available for use in the PowerShell application during the writing of this book. This will help you capture all the commands and outputs from the commands that appear in the console in a text file that you specify using the start-transcript cmdlet.

The Start-transcript cmdlet initializes a transcript file, and then creates records of all the subsequent actions in the PowerShell session.

The syntax is shown as follows:

Here are some of the important parameters that you should know about the start-transcript cmdlet. To save the transcript file to a specified path, use the –Path parameter. You cannot use wildcards when you set the path, but you can also use variables. The directories in the path must exist or the command will fail.

The default behavior of the Start-Transcript cmdlet is to overwrite any file that is in the transcript path unless the –noClobber parameter is specified, which prevents Windows PowerShell from overwriting an existing file.

The –Appendparameter will add the new transcript to the end of an existing file. For example, take a look at the following:

PS C:\> Start-Transcript -Path C:\transcript\transcript01.txt –NoClobber

When you want to stop recording the transcript, you can either exit the console or type Stop-transcript. The Stop-Transcript cmdlet requires no additional parameters.

The Stop-transcript cmdlet stops recording actions that was started by the start-transcript cmdlet. Use the following syntax:

PS C:\> stop-transcript

Using variables