0%

Book Description

PowerShell® is both a scripting language and an administrative shell that lets you control and automate nearly every aspect of IT. In PowerShell for Sysadmins, five-time Microsoft® MVP “Adam the Automator” Bertram shows you how to use PowerShell to manage and automate your desktop and server environments so that you can head out for an early lunch.

You'll learn how to:

•Combine commands, control flow, handle errors, write scripts, run scripts remotely, and test scripts with the PowerShell testing framework, Pester

•Parse structured data like XML and JSON, work with common domains (like Active Directory, Azure, and Amazon Web Services), and create a real-world server inventory script

•Design and build a PowerShell module to demonstrate PowerShell isn’t just about ad-hoc scripts

•Use PowerShell to create a hands-off, completely automated Windows deployment

•Build an entire Active Directory forest from nothing but a Hyper-V host and a few ISO files

•Create endless Web and SQL servers with just a few lines of code!

Real-world examples throughout help bridge the gap between theory and actual system, and the author’s anecdotes keep things lively.

Stop with the expensive software and fancy consultants. Learn how to manage your own environment with PowerShell for Sysadmins and make everyone happy.

Covers Windows PowerShell v5.1

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. BRIEF CONTENTS
  7. CONTENTS IN DETAIL
  8. ACKNOWLEDGMENTS
  9. INTRODUCTION
    1. Why PowerShell?
    2. Who This Book Is For
    3. About This Book
  10. PART I: FUNDAMENTALS
  11. 1 GETTING STARTED
    1. Opening the PowerShell Console
    2. Using DOS Commands
    3. Exploring PowerShell Commands
    4. Getting Help
    5. Updating the Docs
    6. Summary
  12. 2 BASIC POWERSHELL CONCEPTS
    1. Variables
    2. Data Types
    3. Objects
    4. Data Structures
    5. Creating Custom Objects
    6. Summary
  13. 3 COMBINING COMMANDS
    1. Starting a Windows Service
    2. Using the Pipeline
    3. Writing Scripts
    4. Summary
  14. 4 CONTROL FLOW
    1. Understanding Control Flow
    2. Using Conditional Statements
    3. Using Loops
    4. Summary
  15. 5 ERROR HANDLING
    1. Working with Exceptions and Errors
    2. Handling Nonterminating Errors
    3. Handling Terminating Errors
    4. Exploring the $Error Automatic Variable
    5. Summary
  16. 6 WRITING FUNCTIONS
    1. Functions vs. Cmdlets
    2. Defining a Function
    3. Adding Parameters to Functions
    4. Accepting Pipeline Input
    5. Summary
  17. 7 EXPLORING MODULES
    1. Exploring Default Modules
    2. The Components of a PowerShell Module
    3. Working with Custom Modules
    4. Creating Your Own Module
    5. Summary
  18. 8 RUNNING SCRIPTS REMOTELY
    1. Working with Scriptblocks
    2. Working with Sessions
    3. Understanding PowerShell Remoting Authentication
    4. Summary
  19. 9 TESTING WITH PESTER
    1. Introducing Pester
    2. Pester Basics
    3. Executing a Pester Test
    4. Summary
  20. PART II: AUTOMATING DAY-TO-DAY TASKS
  21. 10 PARSING STRUCTURED DATA
    1. CSV Files
    2. Excel Spreadsheets
    3. JSON Data
    4. Summary
  22. 11 AUTOMATING ACTIVE DIRECTORY
    1. Prerequisites
    2. Installing the ActiveDirectory PowerShell Module
    3. Querying and Filtering AD Objects
    4. Creating and Changing AD Objects
    5. Syncing from Other Data Sources
    6. Summary
  23. 12 WORKING WITH AZURE
    1. Prerequisites
    2. Azure Authentication
    3. Creating an Azure Virtual Machine and All Dependencies
    4. Deploying an Azure Web App
    5. Deploying an Azure SQL Database
    6. Summary
  24. 13 WORKING WITH AWS
    1. Prerequisites
    2. AWS Authentication
    3. Creating an AWS EC2 Instance
    4. Deploying an Elastic Beanstalk Application
    5. Creating a SQL Server Database in AWS
    6. Summary
  25. 14 CREATING A SERVER INVENTORY SCRIPT
    1. Prerequisites
    2. Creating the Project Script(s)
    3. Defining the Final Output
    4. Discovery and Script Input
    5. Querying Each Server
    6. Thinking Ahead: Combining Different Types of Information
    7. Querying Remote Files
    8. Querying Windows Management Instrumentation
    9. Windows Services
    10. Script Cleanup and Optimization
    11. Summary
  26. PART III: BUILDING YOUR OWN MODULE
  27. 15 PROVISIONING A VIRTUAL ENVIRONMENT
    1. PowerLab Module Prerequisites
    2. Creating the Module
    3. Automating Virtual Environment Provisioning
    4. Testing the New Functions with Pester
    5. Summary
  28. 16 INSTALLING AN OPERATING SYSTEM
    1. Prerequisites
    2. OS Deployments
    3. Automating OS Deployments
    4. Storing Encrypted Credentials on Disk
    5. PowerShell Direct
    6. Pester Tests
    7. Summary
  29. 17 DEPLOYING ACTIVE DIRECTORY
    1. Prerequisites
    2. Creating an Active Directory Forest
    3. Building the Forest
    4. Building and Running Pester Tests
    5. Summary
  30. 18 CREATING AND CONFIGURING A SQL SERVER
    1. Prerequisites
    2. Creating the Virtual Machine
    3. Installing the Operating System
    4. Adding a Windows Unattended Answer File
    5. Adding the SQL Server to a Domain
    6. Automating the SQL Server
    7. Running Pester Tests
    8. Summary
  31. 19 REFACTORING YOUR CODE
    1. A Second Look at New-PowerLabSqlServer
    2. Using Parameter Sets
    3. Summary
  32. 20 CREATING AND CONFIGURING AN IIS WEB SERVER
    1. Prerequisites
    2. Installation and Setup
    3. Building Web Servers from Scratch
    4. The WebAdministration Module
    5. Configuring SSL on a Website
    6. Summary
  33. INDEX
3.16.218.62