Book Image

Windows Server 2012 Automation with PowerShell Cookbook

By : EDRICK GOAD
Book Image

Windows Server 2012 Automation with PowerShell Cookbook

By: EDRICK GOAD

Overview of this book

Automating server tasks allows administrators to repeatedly perform the same, or similar, tasks over and over again. With PowerShell scripts, you can automate server tasks and reduce manual input, allowing you to focus on more important tasks. Windows Server 2012 Automation with PowerShell Cookbook will show several ways for a Windows administrator to automate and streamline his/her job. Learn how to automate server tasks to ease your day-to-day operations, generate performance and configuration reports, and troubleshoot and resolve critical problems. Windows Server 2012 Automation with PowerShell Cookbook will introduce you to the advantages of using Windows Server 2012 and PowerShell. Each recipe is a building block that can easily be combined to provide larger and more useful scripts to automate your systems. The recipes are packed with examples and real world experience to make the job of managing and administrating Windows servers easier. The book begins with automation of common Windows Networking components such as AD, DHCP, DNS, and PKI, managing Hyper-V, and backing up the server environment. By the end of the book you will be able to use PowerShell scripts to automate tasks such as performance monitoring, reporting, analyzing the environment to match best practices, and troubleshooting.
Table of Contents (19 chapters)
Windows Server 2012 Automation with PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Automating server tasks allows administrators to repeatedly perform the same, or similar, tasks over and over again. With PowerShell scripts, you can automate server tasks and reduce manual input, allowing you to focus on more important tasks.

Windows Server 2012 Automation with PowerShell will show several ways for a Windows administrator to automate and streamline his/her job. Learn how to automate server tasks to ease your day-to-day operations, generate performance and configuration reports, and troubleshoot and resolve critical problems.

Windows Server 2012 Automation with PowerShell will introduce you to the advantages of using Windows Server 2012 and PowerShell. Each recipe is a building block that can easily be combined to provide larger and more useful scripts to automate your systems. The recipes are packed with examples and real world experience to make the job of managing and administrating Windows servers easier.

The book begins with automation of common Windows Networking components such as AD, DHCP, DNS, and PKI, managing Hyper-V, and backing up the server environment. By the end of the book you will be able to use PowerShell scripts to automate tasks such as performance monitoring, reporting, analyzing the environment to match best practices, and troubleshooting.

What this book covers

Chapter 1, Understanding PowerShell Scripting, explains how to use basic PowerShell features such as functions, cmdlets, modules, and loops. These are the basic building blocks of PowerShell that are used repeatedly and in various forms.

Chapter 2, Managing Windows Network Services with PowerShell, covers the installation and configuration of Active Directory, DNS, DHCP, and Certificate Services. This chapter should cover everything necessary to prepare an environment as a fully functioning Active Directory domain for use in labs or new domain build-outs.

Chapter 3, Managing IIS with PowerShell, covers how to install, configure, manage, and maintain IIS websites on Windows Server 8. In addition to basic management of IIS, this will also cover monitoring and reporting of IIS, using NLB for load balancing, and utilizing a dev/staging/prod configuration/promotion scheme. This chapter should cover everything necessary to set up and configure a load-balanced dev/test/prod web environment and automate code promotion.

Chapter 4, Managing Hyper-V with PowerShell, covers installing, configuring, and managing Hyper-V servers and guest OSs. In addition to basic management of Hyper-V, this chapter also covers how to automate the deployment and management of guest VMs, managing VM snapshots, migrate VMs between hosts and prepare a host for maintenance, and how to utilize clustering to make highly-available VMs. This chapter should cover everything necessary to set up and manage an enterprise Hyper-V farm, including reporting, performing maintenance, and monitoring performance.

Chapter 5, Managing Storage with PowerShell, covers how to configure and manage storage using traditional disk, storage pools, reduplication, and SANs.

Chapter 6, Managing Network Shares with PowerShell, covers creating, managing, securing, and using CIFS, NFS, and iSCSI shares. This chapter will also cover how to use server clustering to create highly available network shares, managing replication, and configuring BranchCache.

Chapter 7, Managing Windows Updates with PowerShell, This chapter details the installation and configuration of WSUS as well as the Windows Update client. Additionally, this chapter will include methods to report on installed updates and to automate update installation.

Chapter 8, Managing Printers with PowerShell, covers creation, managing, and updating of printers on print servers. This will also include using PowerShell to map clients to printers and using Windows Clustering to make highly available print servers.

Chapter 9, Troubleshooting Servers with PowerShell, covers utilization of PowerShell troubleshooting packs, Windows Best Practice Analyzers, and using Windows Event Logs. This will also include basic monitoring and configuration of services as well as creating a central Event Log server.

Chapter 10, Managing Performance with PowerShell, shows how to use PowerShell to track and report on historical performance and identify bottlenecks. This chapter will also show how to integrate PowerShell objects with Excel to create usable performance reports and graphs.

Chapter 11, Inventorying Servers with PowerShell, explains how to inventory the hardware and software configurations of Windows 8 servers and create a detailed inventory and configuration report. Additionally, this chapter will cover methods to track configuration changes over time and export the configuration report via Word. This chapter should cover everything necessary to create a centralized hardware and software inventory of all servers in the enterprise.

Chapter 12, Server Backup, covers setting up and scheduling backups on a Windows server. This will include on-demand backups, restoring files, and Windows components, and standardizing the configuration amongst systems.

What you need for this book

To make efficient use of this book, you will need Windows Server 2012 and Microsoft Office to perform code testing and practically implement the recipes mentioned in the book.

Who this book is for

This book is written to assist the daily tasks for systems administrators, engineers, and architects working with Windows Server 2012.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The installer is a fairly simple class, similar to the cmdlet class, which inherits the PSSnapin class and contains overrides that return information about the cmdlet."

A block of code is set as follows:

Function Multiply-Numbers
{
    Param($FirstNum, $SecNum)
    Try
    {
        Write-Host ($FirstNum * $SecNum)
    }
    Catch
    {
        Write-Host "Error in function, present two numbers to multiply"
    }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

Write-Host "Static Size:`t`t" ("{0:0000000000.00}" -f $jenny)
Write-Host "Literal String:`t`t" ("{0:000' Hello '000}" -f $jenny)
Write-Host "Phone Number:`t`t" ("{0:# (###) ### - ####}" -f ($jenny*10000))

Any command-line input or output is written as follows:

Block-SmbShareAccess -Name Share2 -AccountName CORP\joe.smith `
-Confirm:$false 

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

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

To send us general feedback, simply send an e-mail to , and mention the book title via 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 on 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.

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 would 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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 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

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.