Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

PowerShell SysAdmin Crash Course: Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration
PowerShell SysAdmin Crash Course: Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration
PowerShell SysAdmin Crash Course: Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration
Ebook289 pages2 hours

PowerShell SysAdmin Crash Course: Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Take control of your PowerShell skills and start learning today!


Say goodbye to complicated IT tasks and embrace efficient system administration with "PowerShell SysAdmin Crash Course." With hands-on experience and over 50 examples and demonstrations, you will build a strong underst

LanguageEnglish
PublisherGitforGits
Release dateMar 31, 2023
ISBN9788119177196
PowerShell SysAdmin Crash Course: Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration

Related to PowerShell SysAdmin Crash Course

Related ebooks

Programming For You

View More

Related articles

Reviews for PowerShell SysAdmin Crash Course

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    PowerShell SysAdmin Crash Course - Steeve Lee

    PowerShell SysAdmin Crash Course

    PowerShell SysAdmin Crash Course

    Unlock the Full Potential of PowerShell with Advanced Techniques, Automation, Configuration Management and Integration

    Steeve Lee

    Copyright © 2023 GitforGits

    All rights reserved.

    Content

    Preface

    Chapter 1: BEGINNING WITH POWERSHELL

    What is PowerShell?

    Role of PowerShell

    Features of PowerShell

    Benefits of PowerShell

    PowerShell vs. Command Prompt

    Data Processing and Output

    Command Handling

    Features and Capabilities

    Ease of Use

    Sample Program to Compare Differences

    PowerShell Editions and Versions

    Windows PowerShell

    PowerShell Core

    Azure PowerShell

    Exchange Server PowerShell

    SharePoint Server PowerShell

    PowerShell Versions

    Windows PowerShell 1.0

    Windows PowerShell 2.0

    Windows PowerShell 3.0

    Windows PowerShell 4.0

    Windows PowerShell 5.0

    PowerShell 6

    PowerShell 7

    Installing PowerShell

    Check Version of Windows

    Download Appropriate Version of PowerShell

    Run Installer

    Accept License Terms

    Choose Installation Location

    Choose Installation Type

    Install PowerShell

    Launch PowerShell

    Verify the Installation

    Chapter 2: PowerShell Basics

    Configuring PowerShell Console

    Customize PowerShell Profile

    Steps to Customize Profile

    Define Alias, Functions and Variables

    PowerShell ISE

    Overview

    PowerShell ISE Features

    PowerShell ISE vs. Visual Studio Code

    PowerShell Syntax and Grammar

    Variables

    Strings

    Arrays

    If Statements

    For Loops

    While Loops

    Functions

    Chapter 3: Cmdlets, Aliases, and Functions

    Understanding Cmdlets

    Popular 25 Cmdlets

    PowerShell Aliases

    Create Alias

    Modify Alias

    Remove Alias

    Custom Alias

    Modify Existing Alias

    Remove Custom Alias

    PowerShell Functions

    Naming Functions

    Declaring Functions

    Parameters

    Popular Common Functions

    Advanced Functions

    Chapter 4: Up and Running with Scripting Basics

    Variables

    Creating and using variables

    Variable scope

    Global

    Local

    Script

    Private

    Data Types

    String

    Integer

    Float and Double

    Boolean

    Array

    Hashtable

    Operators

    Conditional Statements and Loops

    Conditional Statements

    Loops

    Best Practices

    PowerShell Pipeline

    Common Pipeline Cmdlets

    Output Formatting

    Format-Table

    Format-List

    Format-Wide

    Format-Custom

    Chapter 5: Working with PowerShell Modules

    Introduction to Modules

    Importing and Exporting Modules

    Create Custom PowerShell Module

    Import Custom Module

    Use Function from Imported Module

    Export Specific Functions from Module

    Import Specific Functions

    Creating Custom Modules

    Create a PowerShell Script

    Create Module Manifest File

    Create the Module File

    Test the Module

    Modify the Module

    Test the Modified Module

    Popular Built-in and Community Modules

    Built-in Modules

    Community Modules

    Chapter 6: PowerShell Scripting

    Writing and Executing Scripts

    Plan your Script

    Use Meaningful Variable Names

    Test your Script

    Use Error Handling

    Use try-catch Block

    Writing Error-free Scripts

    Edit PowerShell Scripts

    Understand the Script's Purpose

    Make Copy of Original Script

    Use Version Control

    Test Script Changes

    Modify Existing Script

    Procedure to Modify Script

    Sample Program

    PowerShell Parameters

    Overveiw

    Positional Parameters

    Named Parameters

    Using Parameters in Scripts

    Define Parameters in Script or Function

    Use Parameters within Script or Function

    Call Script or Function with Parameters

    Arguments and Argument Parsing

    Positional Arguments

    Named Arguments

    Default Values

    Mandatory and Optional Parameters

    Type Conversion

    Validation

    Implement and Parse Arguments

    Create MathOperation.ps1 Script

    Run Script with Arguments

    Using Named Arguments

    Debugging PowerShell

    Write-Host and Write-Verbose

    Sample Program: Write-Host and Write-Verbose

    Set-PSBreakpoint

    Sample Program: Set-PSBreakpoint

    Chapter 7: Windows Management with PowerShell

    Managing Files, Folders, and Drives

    Navigating File System

    Creating and Removing Directories

    Creating, Reading, and Editing Files

    Copying, Moving, and Renaming Files and Folders

    Working with Drives

    Filtering and Sorting Items

    Working with File and Folder Attributes

    Calculating Folder Size

    Working with the Windows Registry

    Navigating the Registry

    Reading Registry Keys and Values

    Creating and Removing Registry Keys

    Creating, Modifying, and Removing Registry Values

    Exporting and Importing Registry Keys

    Searching Registry

    Managing Processes, Services, and Event Logs

    Processes

    Services

    Event Logs

    Viewing Available Event Logs

    Reading Event Logs

    Filtering Event Logs

    Searching for Specific Event IDs

    Exporting Event Logs

    Clearing Event Logs

    Creating and Managing Custom Event Logs

    Managing Scheduled Tasks

    Listing Scheduled Tasks

    Getting Information Of a Specific Task

    Creating New Scheduled Task

    Updating Existing Scheduled Task

    Running Scheduled Task Manually

    Stopping Running Scheduled Task

    Enabling and Disabling Scheduled Task

    Removing Scheduled Task

    Chapter 8: Active Directory Management

    Active Directory PowerShell Module

    Discoverability

    Managing Users

    Managing Groups

    Managing Computers

    Managing Organizational Units (OUs)

    Installing Active Directory Module

    Manage AD Users

    Manage AD Groups

    Manage Computer

    Manage Organizational Units (OUs)

    Manage Group Policy Objects (GPOs)

    Managing Active Directory Sites and Replication

    Chapter 9: PowerShell Remoting

    PowerShell Remoting

    Windows Remote Management (WinRM)

    PowerShell Sessions (PSSessions)

    Implicit Remoting

    Security and Authentication

    Execution Policy

    Remote Commands and Scriptblocks

    One-to-One Remoting

    Interactive Session

    Invoking Commands

    One-to-Many Remoting

    Array Example

    Text File Example

    Sessions and Persistent Connections

    Creating a PSSession

    Executing Commands using a PSSession

    Entering and Exiting Interactive PSSession

    Importing Remote Commands using a PSSession

    Removing a PSSession

    Remote Troubleshooting and Management

    Gathering System Information

    Replace RemoteComputer with Remote Machine's Name

    Managing Processes

    Managing Windows Features

    Executing Scripts on Remote Machines

    Securing PowerShell Remoting

    Configure WinRM Service

    Use Secure Transports

    Configure Firewall Rules

    Use Strong Authentication Mechanisms

    Restrict User Access

    Configure Execution Policy

    Auditing and Logging

    Update PowerShell and Related Components

    Chapter 10: PowerShell Desired State Configuration (DSC)

    Introduction to DSC

    DSC Benefits for SysAdmin

    Writing and Applying DSC Configurations

    Writing DSC Configurations

    Applying DSC Configurations

    Creating Custom DSC Resources

    Design the Resource

    Implement the Resource

    Package the Resource

    DSC Configuration Management and Reporting

    Local Configuration Manager (LCM) Logs

    DSC Reporting Through Pull Server

    Chapter 11: PowerShell and System Center Configuration Manager (SCCM)

    Understanding SCCM

    Automation

    Integration

    Customization

    Troubleshooting

    Procedure to Use SCCM with PowerShell

    Load SCCM PowerShell Module

    Connect to SCCM Site

    Query Device Collections

    Create New Device Collection

    Deploy Application

    Deploying and Managing Applications

    Create Application in SCCM

    Distribute the Application Content

    Deploy Application to Target Collection

    Monitor the Deployment

    Managing Software Updates and Patches

    Synchronize Software Updates

    Create a Software Update Group

    Add Updates to Software Update Group

    Deploy Software Update Group

    Monitor the Deployment

    Operating System Deployment Automation

    Create and Customize an Operating System Image

    Create a Task Sequence

    Add Steps to Task Sequence

    Deploy the Task Sequence

    Monitor the Deployment

    SCCM Reporting and Monitoring

    Load SCCM PowerShell Module

    Retrieve SCCM Data

    Generate Reports

    Schedule Reports

    Chapter 12: PowerShell Security and Best Practices

    Secure Coding Practices

    Need for Secure Coding Practices

    Key Secure Coding Practices in PowerShell

    PowerShell Execution Policy

    Editing PowerShell Execution Policy

    Sample Program to Edit Execution Policy

    Bypassing PowerShell Execution Policy

    Sample Program to Bypass Execution Policy

    Constrained Language Mode

    Overview

    Enable and Disable Constrained Language Mode

    Bypass Constrained Language Mode

    Sample Program to Bypass Constrained Language Mode

    Implementing Just Enough Administration (JEA)

    Install JEA PowerShell Module

    Define a Role Capability File

    Create a Session Configuration File

    Register the JEA Endpoint

    Test the JEA Endpoint

    Auditing and Logging PowerShell Activities

    Necessity of Auditing and Logging PowerShell Activities

    Implementing Auditing and Logging PowerShell Activities

    Sample program to enable powershell logging

    Sample Program to Use Script Block Logging

    Chapter 13: Advanced PowerShell Techniques

    Regular Expressions and Text Manipulation

    -match Operator

    -replace Operator

    Matches() Method

    Split() Method

    Replace() Method

    Working with XML and JSON Data

    Import-Clixml

    Export-Clixml

    Select-Xml

    ConvertTo-Xml

    ConvertFrom-Json

    ConvertTo-Json

    Multithreading and Parallel Processing

    ForEach-Object -Parallel

    -ThrottleLimit

    Creating Custom Cmdlets and Modules

    Using .NET Framework and Assemblies

    Accessing .NET Classes

    Creating .NET Objects

    Accessing Properties and Methods

    Adding .NET Assemblies

    Using .NET Assemblies

    Using .NET Namespaces

    Creating Custom .NET Classes

    Chapter 14: PowerShell and Automation Frameworks

    Introduction to Automation Frameworks

    Script Organization and Management

    Consistency and Best Practices

    Workflow and Process Automation

    Testing and Validation

    Continuous Integration and Continuous Deployment (CI/CD)

    Cross-platform Compatibility

    PowerShell and Ansible

    Prerequisites

    Configure Ansible Inventory File

    Test Connection to Windows Hosts

    Use PowerShell in Ansible Playbooks

    Run the Playbook

    Use Ansible Windows Modules

    PowerShell and Chef

    Prerequisites

    Create a Chef Cookbook

    Create Recipe to Run PowerShell Commands

    Add Recipe to run-list

    Upload Cookbook to Chef Server

    Assign Cookbook to Windows Nodes

    Run Chef Client on Windows Nodes

    PowerShell and Puppet

    Prerequisites

    Create Puppet Module

    Create Puppet Manifest to Run PowerShell Commands

    Add Class to Main Manifest

    Upload Module to Puppet Server

    Assign Module to Windows Nodes

    Run Puppet Agent on Windows Nodes

    Integrating PowerShell with CI/CD Tools

    Prerequisites

    Install PowerShell Plugin

    Create Jenkins Job

    Add PowerShell Build Step

    Run Jenkins Job

    Configure post-build Actions (optional)

    Chapter 15: Extending PowerShell and Interoperability

    Extending PowerShell

    Interoperability

    Integrating PowerShell with Python, and Bash

    Integrating PowerShell with Python

    Integrating PowerShell with Bash

    PowerShell and RESTful APIs

    Invoke-RestMethod

    Invoke-WebRequest

    Creating and Consuming Web Services

    Create Web Service using PowerShell

    Consume Web Service

    Chapter 16: Working with PowerShell Universal

    Why PowerShell Universal?

    Configure PowerShell Universal

    Install PowerShell Universal

    Configure PowerShell Universal

    Access PowerShell Universal

    Configure settings

    Create Scripts, APIs, and Dashboards

    Configure PowerShell Universal as-a-Service (optional)

    Run scripts

    Create New Script

    Edit the Script

    Run the Script

    View Script Hstory and Output

    Powershell scheduling

    Create a New Schedule

    Assign Script to Schedule

    Preface

    PowerShell SysAdmin Crash Course is the ultimate guide for system administrators and PowerShell users. This comprehensive resource teaches readers everything they need to know about PowerShell, from the console and cmdlets to scripting, modules, and more.

    With hands-on experience and over 50 examples and demonstrations, readers will build a strong understanding of PowerShell and gain confidence in its application. They will also learn essential topics like Active Directory Management, PowerShell Remoting, DSC, SCCM, and administering software updates.

    In addition, readers will discover advanced techniques such as working with JSON and XML data, parallel processing, multithreading, and creating custom cmdlets and modules. They will also learn how to integrate PowerShell with automation and configuration management tools like Ansible, Puppet, and Chef, and how to use CI/CD tools like Jenkins. The book also covers integrating PowerShell with Bash and Python scripting and utilizing PowerShell Universal for running automation scripts through a single platform.

    In this book you will learn how to:

    Learn everything about PowerShell, from console to cmdlets to scripting and modules.

    Manage Active Directory, PowerShell Remoting, DSC, SCCM, and software updates.

    Discover advanced techniques like JSON and XML data, parallel processing, and multithreading.

    Create custom cmdlets and modules for automation and configuration management.

    Integrate PowerShell with Ansible, Puppet, Chef, Jenkins, Bash, and Python scripting.

    Use PowerShell Universal to run automation scripts through a single platform.

    Say goodbye to complicated IT tasks and embrace efficient system administration with PowerShell SysAdmin Crash Course. Take control of your PowerShell skills and start learning today!

    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 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 kittenpub.kdp@gmail.com. 

    We are happy to assist and clarify any concerns.

    Acknowledgement

    I owe a tremendous debt of gratitude to GitforGits, my editor, for their unflagging enthusiasm and wise counsel throughout the entire process of writing this book. Their knowledge and careful editing helped make sure the piece was useful for people of all reading levels and comprehension skills. In addition, I'd like to thank everyone involved in the publishing process for their efforts in making this book a reality. Their efforts, from copyediting to advertising, made the project what it is today.

    Finally, I'd like to express my gratitude to everyone who has shown me unconditional love and encouragement throughout my life. Their support was crucial to the completion of this book. I appreciate your help with this endeavour and your continued interest

    Enjoying the preview?
    Page 1 of 1