Book Image

Mastering Windows PowerShell Scripting

By : Brenton J.W. Blawat
Book Image

Mastering Windows PowerShell Scripting

By: Brenton J.W. Blawat

Overview of this book

Table of Contents (22 chapters)
Mastering Windows PowerShell Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

String manipulation


String manipulation is something that you'll need to do in almost every script you create. While some of the string methods will be used more often than others, they all serve different purposes for your script. It is ultimately up to your creativity on how you want data to look when it is displayed on the screen.

To change the text to uppercase, execute the following command:

$a = "Error: This is an example error"
$a.toUpper()

The output of this is shown in the following screenshot:

The toUpper() method is used to format the text to uppercase. This is helpful in situations where messages need to be emphasized or should stand out. The result of this command will change the case.

To change the string to lowercase, execute the following command:

$string = "The MAC Address is " 
$mac = "00:A0:AA:BB:CC:DD"
$message = $string + $mac.toLower()
$message

The output of this is shown in the following screenshot:

The inverse of toUpper() is the use of toLower(). This command will convert...