Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Convert Names to Proper Case?

Hey, Scripting Guy! I have a script that my help desk people use to create user accounts. Unfortunately, sometimes these help desk personnel get in a hurry and type in names like this: kEn MYEr. How can I convert names to proper case (i.e., Ken Myer)?-- LC Hey, LC. You know what: you’re in luck. Usually when it comes to doing anything ...

How Can I Compare Two String Values Regardless of Letter Case?

Hey, Scripting Guy! I have a script that compares two email addresses and tells me whether or not they are the same. Sometimes the email addresses are the same, but the case is different: for example, one address might be example@abc.com and the other might be example@ABC.com. My script always tells me that these are different email ...

How Can I Pick Out and Save Specific Lines in a Text File?

Hey, Scripting Guy! I’d like to be able to read through a text file, select the lines that begin with a particular word (like Failure), and then save only those lines back to the same text file. Is there any way to do that?-- AC Hey, AC. Hey, AC. For simplicity’s sake, we’re assuming you have a text file that looks similar to this:...

How Do I Get Rid of Extraneous Spaces in a String?

I know that I can use the Split command to separate a sentence like this - VBScript is fun! - into an array of individual words. However, what happens if I have a sentence like this: VBScript is fun! I can’t use a blank space as the delimiter because I might have lots of blank spaces. And I can’t use a specific number of blank spaces as ...

Can I Enable the Caps Lock Key?

Hey, Scripting Guy! I have a script where users enter some information in an Input box. The information needs to be entered in all-capital letters, so my instructions say, “Please make sure the Caps Lock key is on before entering the information.” They don’t always do that, however. Is there a way to turn the Caps Lock key on and off ...