Book Image

Enterprise PowerShell Scripting Bootcamp

By : Brenton J.W. Blawat
Book Image

Enterprise PowerShell Scripting Bootcamp

By: Brenton J.W. Blawat

Overview of this book

Enterprise PowerShell Scripting Bootcamp explains how to create your own repeatable PowerShell scripting framework. This framework contains script logging methodologies, answer file interactions, and string encryption and decryption strategies. This book focuses on evaluating individual components to identify the system’s function, role, and unique characteristics. To do this, you will leverage built-in CMDlets and Windows Management Instrumentation (WMI) to explore Windows services, Windows processes, Windows features, scheduled tasks, and disk statistics. You will also create custom functions to perform a deep search for specific strings in files and evaluate installed software through executable properties. We will then discuss different scripting techniques to improve the efficiency of scripts. By leveraging several small changes to your code, you can increase the execution performance by over 130%. By the end of this book, you will be able to tie all of the concepts together in a PowerShell-based Windows server scanning script. This discovery script will be able to scan a Windows server to identify a multitude of components.
Table of Contents (21 chapters)
Enterprise PowerShell Scripting Bootcamp
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
3
Working with Answer Files
Index

Chapter 11. Improving Performance by Using Regular Expressions

As you are evaluating systems with the Windows Server scanning script, there may be instances where you need to find sensitive data that doesn't match specific values. Credit card numbers, social security numbers, and even tax identification numbers are great examples of data that you need to identify, but would be impossible to search for using strings alone.

Regular expressions, however, provide pattern matching to identify data that you normally wouldn't be able to find with string searching. Regular expressions are very dynamic and can be used to detect any pattern that you need in your script. In fact, regular expressions can be so granular that they can search parts of words. This means that you can find the word Password in the MyPasswordIsString string.

Regular expressions are also very quick. In comparison to using multiple arrays and if statements, regular expressions often outperform other techniques by over 50%! This...