Master PowerShell Tricks Volume 2
Master PowerShell Tricks Volume 2
Minimum price
Suggested price
Master PowerShell Tricks Volume 2

Last updated on 2018-01-19

About the Book

There are many cool things about Windows PowerShell. For me three of the most awesome things are the following:

1. If you don’t like the way Windows PowerShell does things, you can change it.

2. If Windows PowerShell can’t do something you need, you can add it.

3. The Windows PowerShell community is super dedicated, and will help you do both one and two. 

Now, to be honest at times, it is necessary to write hundreds and hundreds of lines of arcane code, to dive into the deepest and darkest mysteries of programing, and even to learn about things like API’s, Constructors, Events, threading, ACL’s, DACL’s, CACL’s and maybe even Tetradactylies. Then again, most of the time it is not. In fact, it has been years and years since I wrote a hundreds and hundreds of lines of arcane code. 

It is almost as if the Windows PowerShell team deliberately tried to make Windows PowerShell easy to use and easy to learn. Hmm … I wonder if that approach would ever catch on? Anyway, there used to be an old saw: “Ease of use is directly opposed to program capability.” Or, in other words, if it is easy to use, it probably is not all that powerful. Well, PowerShell changes that … dramatically. 

And yet, Windows PowerShell is also deceptively easy to use. One can go from Get-Service and Get-Process or even Get-Date to some pretty complicated stuff in like one line of code. 

This is why item number three is so important. The authors of this book: Dave, Sean, Will, Mick, Thomas and Allan are all Windows PowerShell experts, and have even been recognized by Microsoft as community leaders. So, this means not only do they know their stuff, but they are also great at sharing that knowledge with the community. Sean Kearney is even an Honorary Scripting Guy – a very elite group indeed!

One of the great way that MVP’s share their knowledge and experience is via MVP Days a traveling road show that was started by Dave and Cristal Kawula. This is a very well run event, and I have had the opportunity to speak at two of the events … it is cool, and it is fun.

So grab this book, get it autographed, and learn how to master some awesome PowerShell tricks. It is cool. 


Ed Wilson

Microsoft Scripting Guy


About the Authors

Dave Kawula
Dave Kawula

Dave is a Microsoft Most Valuable Professional (MVP) with over 20 years of experience in the IT industry. His background includes data communications networks within multi-server environments, and he has led architecture teams for virtualization, System Center, Exchange, Active Directory, and Internet gateways. Very active within the Microsoft technical and consulting teams, Dave has provided deep-dive technical knowledge and subject matter expertise on various System Center and operating system topics.

Dave is well-known in the community as an evangelist for Microsoft, 1E, and Veeam technologies. Locating Dave is easy as he speaks at several conferences and sessions each year, including TechEd, Ignite, MVP Days Community Roadshow, and VeeamOn. 

Recently Dave has been honored to take on the role of Conference Co-Chair of TechMentor with fellow MVP Sami Laiho.  The lineup of speakers and attendees that have been to this conference over the past 20 years is really amazing. Come down to Redmond or Orlando in 2018 and you can meet him in person.

As the founder and Managing Principal Consultant at TriCon Elite Consulting, Dave is a leading technology expert for both local customers and large international enterprises, providing optimal guidance and methodologies to achieve and maintain an efficient infrastructure.


Twitter: @DaveKawula

Thomas Rayner
Thomas Rayner

Thomas Rayner is a Microsoft Most Valuable Professional (MVP) and Honorary Scripting Guy with many years of experience in IT. He is a master technologist, specializing in DevOps, systems and process automation, public, private and hybrid cloud, and PowerShell. Thomas is an international speaker, best-selling author, and instructor covering a vast array of IT topics.

Allan Rafuse
Allan Rafuse

Allan is a Microsoft Most Valuable Professional (MVP) and a Veeam Vanguard. Throughout his career, his skills have allowed him to work in variety of different industries (Oil and Gas, Banking and Healthcare) and also move to several Canadian provinces and even live in Europe. He has worked in many job roles that support the data center stack and cloud components and is also well versed in designing and deploying robust, highly available enterprise solutions in single or multi datacenter environments.

Integrating products and automation are passions of Allan. His solutions usually employ virtual environments (Hyper-V, VMware), Active Directory, SQL Server, System Center (SCCM, SCOM, SCVMM, SCORCH), Windows Server, Exchange, PowerShell, Veeam products and even Linux. He is an expert at scripting solutions and has an uncanny ability to reduce complexity and maximize the functionality of PowerShell.

Allan is a huge tech evangelist and the founder and Managing Principal Consultant at BroadArc Consulting. His consulting skills, vision, methodologies and frameworks have allowed many projects and solutions to thrive and succeed.

If you haven’t had the chance to personally meet Allan’s at an IT community speaking, you can always virtually follow him and introduce yourself on his blog or twitter.

BLOG: | Twitter: @AllanRafuse | LinkedIn:

Bundles that include this book

Master PowerShell Tricks Volume 1
Master PowerShell Tricks Volume 2
Master PowerShell Tricks Volume 3
Suggested Price
Bundle Price

Table of Contents

Foreword Ed Wilson “The Scripting Guy” iii

Acknowledgements v

From Dave v

About the Authors vi

Dave Kawula - MVP vi

Sean Kearney - MVP vii

Thomas Rayner - MVP vii

Allan Rafuse – MVP viii

Will Anderson – MVP ix

Mick Pletcher – MVP x

Ed Wilson – The Scripting Guy xi

Technical Editors xii

Cristal Kawula – MVP xii

Emile Cabot - MVP xii

Kai Poynting xiii

Contents xiv

Introduction 1

North American MVPDays Community Roadshow 1

Structure of the Book 2

Sample Files 3

Additional Resources 3

Chapter 1 5

PowerShell Regex to Get Value Between Quotation Marks 5

Chapter 2 7

How to Send an Email Whenever a File Gets Changed 7

Chapter 3 8

Using PowerShell to Add Groups to Accept messages only Distribution list members 8

The Code 9

Chapter 4 10

Installing and Finding Modules 10

Why use Install-Modules 10

Module Dependencies 10

Repositories 11

Managing Repositories 11

Finding Modules in the Repositories 11

Installing a Module 13

Proxy Configuration 14

Summary 14

Chapter 5 15

Use PowerShell to Validate Parameters for you 15

Common PowerShell Functions – NO Validation 16

PowerShell Features for Parameters 16

Problem 1 16

Problem 2 17

Problem 3 17

Solution 18

Other Parameter Validation Features 18

Chapter 6 19

PowerShell – My Way to Prepare a SQL Server VM 19

Template File 20

A look at library-PrepareSQLServer.ps1 21

Running the script 23

Chapter 7 25

Building Gold VHDx images with PowerShell 25

Define the Variables 26

Build $unnatendSource 26

Get-UnattendChunk 27

New-Unattendfile 28

New-BaseImage 29

Chapter 8 32

Using Try Catch to help with Decision Making in a Script 32

Chapter 9 36

Invoking your SCCM Client Remotely with PowerShell 36

Chapter 10 38

Use PoweShell to Parse RSS Feeds 38

Chapter 11 44

How to alter the public IP Address of an Azure Virtual Machine using PowerShell 44

The Challenge 44

Data formatting or using an existing example 44

Make the change 46

Chapter 12 48

Get the Public IP of an Azure VM with PowerShell 48

Chapter 13 49

SCCM Local Administrator Reporting with PowerShell 49

LocalAdmins.ps1 53

Chapter 14 58

Configuring Power Settings using PowerShell 58

Set-PowerScheme.ps1 58

Chapter 15 73

Automated SCCM Endpoint Full System Scan upon Infection with Email Notification 73

ApplicationVirusDetectionMethodEmail.ps1 75

AntiVirusScanEmail.ps1 76

Chapter 16 79

Laptop Mandatory Reboot Management with SCCM and PowerShell 79

MandatoryReboot.ps1 80

MandatoryRebootCustomDetection.ps1 82

Chapter 17 84

Set Windows Features with Verification 84

WindowsFeatures.ps1 85

Chapter 18 90

Easily Restore a Deleted Active Directory User with PowerShell 90

Chapter 19 91

Getting Large Exchange Mailbox Folders with PowerShell 91

Chapter 20 95

Getting your Organizations Largest Exchange Mailboxes with PowerShell 95

Chapter 21 99

Just Enough Administration (JEA) First Look 99

So how do you get started? 99

Chapter 22 105

Does a String Start or End in a Certain Character? 105

Chapter 23 107

Using PowerShell to List All the Fonts in a Word Document 107

Chapter 24 109

Find PowerShell Scripts in the GUI 109

Chapter 25 116

How to use PowerShell as an Administrative Console 116

Chapter 26 118

How to Erase Files based on Date using PowerShell 118

Chapter 27 121

Join us at MVPDays and meet great MVP’s like this in person 121

Live Presentations 121

Video Training 121

Live Instructor-led Classes 121

Consulting Services 122

Twitter 123

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub