Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering PowerShell Scripting
  • Table Of Contents Toc
Mastering PowerShell Scripting

Mastering PowerShell Scripting - Fifth Edition

By : Chris Dent
4.9 (28)
close
close
Mastering PowerShell Scripting

Mastering PowerShell Scripting

4.9 (28)
By: Chris Dent

Overview of this book

Mastering PowerShell Scripting, Fifth Edition, is your comprehensive guide to harnessing PowerShell’s full potential. This edition introduces new chapters on debugging, troubleshooting, and creating GUIs while covering the latest enhancements in PowerShell 7.3, including parameters, objects, and .NET classes. The book takes you from foundational concepts to advanced techniques, covering asynchronous processing, desired state configuration, and managing large datasets. You'll explore PowerShell’s automation features, error-handling strategies, and integration with external services. Additionally, this guide provides practical insights into working with regular expressions, Windows Management Instrumentation, and complex scripting methods. By the end of this book, you’ll have the skills to efficiently automate tasks, troubleshoot scripts, and leverage PowerShell’s advanced capabilities for real-world scenarios. Be sure to explore the online bonus chapters 8, 9, and 20, where we dive into Strings, Numbers, and Dates, Regular Expressions, and Building Modules.
Table of Contents (23 chapters)
close
close
Preface
21
Other Books You May Enjoy
22
Index

Debugging other PowerShell processes

A PowerShell developer can make use of Enter-PSHostProcess to debug a script running in a different PowerShell process.

The Enter-PSHostProcess command creates a remote runspace inside an existing PowerShell process.

Demonstrating use requires two PowerShell processes. The first PowerShell process is started, and for convenience, the PID of that process is shown.

A simple infinite loop is started after setting the window title to show the current PID:

$host.UI.RawUI.WindowTitle = 'Script runner: {0}' -f $PID
$i = 0
while ($true) {
    Write-Host "Working on $i"
    $i++
    Start-Sleep -Seconds 30
}

In the example that follows, the first process showed a PID of 14504 and is used to connect to that process. This PID will be different in each case.

A second process is started and the Enter-PSHostProcess command is used to connect to the original PID. The prompt will change to reflect the connection to...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering PowerShell Scripting
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon