Share E-Book

AuthorSteeve Lee

This second edition is a hands-on, practical book crafted to empower system administrators and PowerShell enthusiasts to efficiently perform everyday system administration tasks and to automate complex processes with confidence. This book will take you from the basics of PowerShell scripting to advanced techniques and beyond. You will gain hands-on experience with handling variables, data types, and loops while learning to create reliable scripts that manage files, folders, drives, and the Windows registry. You will be introduced to powerful features such as remoting, DSC, and integration with System Center Configuration Manager to ensure that you can manage and deploy configurations across distributed environments.

AI Reading Assistant

Summary and highlights from this book's index; jump to passages in the text

Passage locations
Tags
No tags
Publisher: GitforGits
Publish Year: 2025
Language: 英文
File Format: PDF
File Size: 6.4 MB
Support Statistics
¥.00 · 0times
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Second Edition fCitforGits® 3 ASIAN PUBLISHING HOUSE PowerShell SysAdmin Crash Course Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration
PowerShell SysAdmin Crash Course Second Edition Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration Steeve Lee
Preface This second edition is a hands-on, practical book crafted to empower system administrators and PowerShell enthusiasts to efficiently perform everyday system administration tasks and to automate complex processes with confidence. This book will take you from the basics of PowerShell scripting to advanced techniques and beyond. You will gain hands-on experience with handling variables, data types, and loops while learning to create reliable scripts that manage files, folders, drives, and the Windows registry. You will be introduced to powerful features such as remoting, DSC, and integration with System Center Configuration Manager to ensure that you can manage and deploy configurations across distributed environments. Additionally, the book covers the intersection of PowerShell with modern automation frameworks, including Ansible, Chef, Puppet, and popular CI/CD tools. Such integration helps you streamline deployments, orchestrate workflows, and maintain consistent configurations across Windows and cross-platform systems. It also covers advanced topics such as extending PowerShell through custom cmdlets, modules, and classes, as well as techniques to interact with external systems via RESTful APIs, Python, and Bash. With simple and straightforward examples, the book presents many aspects of system administration while also touching on more complex scenarios, giving you the insight you
need to tackle challenging environments without overwhelming you. In this book: You will be up and running with PowerShell scripting for system administration tasks. Use effective commands to manage files, folders, drives, and the Windows Registry. Use PowerShell remoting to securely manage multiple systems. Apply Desired State Configuration for automated, idempotent, and consistent infrastructure management. Integrate SCCM to automate deployments, software updates, and system configurations. Leverage advanced text manipulation with regular expressions for precise data extraction and transformation. Develop custom modules, cmdlets, and functions to effectively extend PowerShell's native capabilities. Employ multithreading and parallel processing to enhance script performance. Integrate PowerShell with Ansible, Chef, and Puppet. Safeguard PowerShell environments by implementing best practices, execution policies, and robust auditing techniques.
GitforGits Prerequisites This book is ideal for those who want to build a strong understanding of PowerShell and its application, from the basics to advanced techniques. It is also suitable for those who want to integrate PowerShell with automation and configuration management tools and other scripting languages. Codes Usage Are you in need of some helpful code examples to assist you in your programming and documentation? Look no further! Our book offers a wealth of supplemental material, including code examples and exercises. Not only is this book here to aid you in getting your job done, but you have our permission to use the example code in your programs and documentation. However, please note that if you are reproducing a significant portion of the code, we do require you to contact us for permission.
But don't worry, using several chunks of code from this book in your program or answering a question by citing our book and quoting example code does not require permission. But if you do choose to give credit, an attribution typically includes the title, author, publisher, and ISBN. For example, "PowerShell SysAdmin Crash Course, Second Edition by Steeve Lee". If you are unsure whether your intended use of the code examples falls under fair use or the permissions outlined above, please do not hesitate to reach out to us at We are happy to assist and clarify any concerns.
Prologue My name is Steeve Lee, and I'm excited to present the second edition of "PowerShell SysAdmin Crash Course." The first edition did better than I expected, and the great reviews and helpful feedback made it clear that people really liked it. That made me want to do even more to refine and expand the content. People loved the hands-on approach, and I took the suggestions to heart. They told me to add more practical examples and to cover more real-world scenarios. This edition builds on that success, offering deeper insights and additional techniques that I believe will change how you work with PowerShell. In this book, I'll take you on a fundamentals exploration that quickly progresses to powerful, time-saving methods that can transform your day-to-day administrative tasks. I share my own experiences, challenges, and discoveries from the field, so you can see how PowerShell can be a true game-changer in managing IT environments. As you flip through the pages, you'll come across hands-on tasks like handling files, directories, and the registry, plus automating repetitive tasks with ease. I've put a lot of real-world scenarios in this edition, based on what I've seen in my own career. You'll learn how to use PowerShell to manage multiple systems remotely, deploy updates,
and monitor environments easily. I also explore ways to expand PowerShell's functionality, like creating custom modules and integrating it with modern automation tools. This book is designed to give you practical, hands-on examples that you can apply right away in your own workplace. One thing I focused on was making the content as easy to access as possible. I made the explanations clear and straightforward, so even complex topics feel approachable. I also included a bunch of examples that you can try on your own. The whole point of the book is to help you build your confidence, step-by-step, from writing basic scripts to automating more complex tasks across different environments. Whether you're a pro or just getting started, you'll find techniques that'll help you get more done and make your daily operations more efficient. I share the practical knowledge and best practices I've learned over the years. I'm a big believer in the power of automation and efficiency, and I'm excited to pass on the skills that have helped me solve real challenges in the field. I'm excited to hear how this edition helps you transform your system administration approach, and I hope you enjoy the journey. My goal is to help you get the most out of PowerShell and make a real difference in your day-to-day management tasks.
^GitforGits® ASIAN PUBLISHING HOUSE Copyright © 2025 by GitforGits All rights reserved. This book is protected under copyright laws and no part of it may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without the prior written permission of the publisher. Any unauthorized reproduction, distribution, or transmission of this work may result in civil and criminal penalties and will be dealt with in the respective jurisdiction at anywhere in India, in accordance with the applicable copyright laws. Published by: GitforGits Publisher: Sonal Dhandre www.gitforgits.com
support@gitforgits.com Printed in India First Printing: January 2025 Cover Design by: Kitten Publishing For permission to use material from this book, please contact GitforGits at support@gitforgits.com.
Content Preface GitforGits Acknowledgement Chapter 1: Beginning with PowerShell Chapter Overview What is PowerShell? Essence of PowerShell Core Features of PowerShell Customization and Extensibility Cross-Platform and Security Considerations Embracing the Power of PowerShell PowerShell vs. Command Prompt Data Processing Command Handling and Syntax Pipeline and Data Flow Ease of Use and Learning Curve
Interactive Features and Customization Operational Benefit PowerShell Editions and Versions Windows PowerShell PowerShell Core Azure PowerShell Exchange Server PowerShell SharePoint Server PowerShell PowerShell Versions PowerShell 1 and 2 PowerShell 3 and 4 PowerShell 5 and 5.1 PowerShell 6 PowerShell 7, 7.1, 7.2, and 7.3 Installing PowerShell Access to PowerShell 7.3 Packages Installing PowerShell Package Verifying Install Summary Chapter 2: PowerShell Basics
Chapter Overview Configuring PowerShell Console Adjusting Appearance and Behavior Tweaking Layout and Buffer Settings PowerShell 7.3 Enhancements Customize PowerShell Profile Creating and Editing Profile Defining Aliases and Functions Setting Variables and Importing Modules Customizing Prompt Testing Customizations PowerShell Syntax and Grammar Summary Chapter 3: Cmdlets, Aliases, and Functions Chapter Overview Exploring Cmdlets Get-Process Get-Service
Get-ChildItem Get-ItemProperty Set-Location New-Item Remove-Item Rename-Item Start-Process Stop-Process Get-Content Set-Content Out-File Get-Date Get-Host Get-Module Import-Module Export-CSV Test-Connection New-ADUser Get-ADUser Set-ADUser Get-ADComputer Enable-ADAccount Disable-ADAccount PowerShell Aliases Creating Aliases Modifying Aliases
PowerShell Functions Defining a Simple Function Working with Parameters Advanced Function Features Summary Chapter 4: Up and Running with Scripting Basics Chapter Overview Variables Creating Variables Data Types Variable Scope Global Scope Local Scope Script Scope Private Scope Data Types Working with Strings and Numbers Arrays and Hashtables
Conditional Statements and Loops Conditional Statements Looping Constructs For Loop Foreach Loop While Loop Do-While Loop PowerShell Pipeline Output Formatting Formatting with Format-Table Using Format-List Format-Wide and Format-Custom Summary Chapter 5: Working with PowerShell Modules Chapter Overview Importing and Exporting Modules Importing Modules Exporting Modules
Creating and Managing Custom Modules Creating Custom Modules Writing Module Functions Creating a Module Manifest Importing and Exporting Functions Testing Custom Module Summary Chapter 6: PowerShell Scripting Chapter Overview Writing and Executing Scripts Planning and Structure Script Implementation Modify Existing Script Identifying Modification Requirements Implementing Changes Testing Modified Script PowerShell Parameters Defining Parameters Mandatory, Optional, and Default Values
Parameter Validation Using Parameter Sets Pipeline Input Sample Program: Automated Backup Using Parameters Arguments and Argument Parsing Sample Program: Multi-Mode Backup Parsing Arguments from Pipeline Summary Chapter 7: Windows Management with PowerShell Chapter Overview Managing Files, Folders, and Drives Creating and Removing Directories Creating, Reading, and Editing Files Copying, Moving, and Renaming Working with Drives Filtering, Sorting, and Attributes Calculating Folder Size
Working with Windows Registry Navigating Registry Reading Registry Keys and Values Creating and Removing Registry Keys Managing Registry Values Exporting and Importing Registry Keys Searching Registry Managing Processes, Services, and Event Logs Managing Processes Listing Processes Starting and Stopping Processes Working with Services Listing and Filtering Services Controlling Services Monitoring and Managing Event Logs Viewing Event Logs Reading Specific Logs Filtering and Searching Exporting and Clearing Logs Sample Program: A Health Check Script Managing Scheduled Tasks Listing and Retrieving Tasks Creating New Scheduled Tasks Define Action
Define Trigger Register Task Modifying Existing Scheduled Tasks Running and Stopping Scheduled Tasks Enabling, Disabling, and Removing Tasks Sample Program: Holistic Maintenance Task Summary Chapter 8: Active Directory Management Chapter Overview Active Directory PowerShell Module Discovering Module’s Structure and Cmdlets Managing Users, Groups, and Computers Organizing with Organizational Units Advanced Features and Scripting Integration Installing Active Directory Module Installing on Windows Server Installing on Windows Manage AD Users Creating New User Accounts Retrieving User Information