Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Latest posts

Apr 15, 2016
Post comments count 0
Post likes count 0

PowerTip: Use a regular expression pattern to remove nonalphabetic characters

Doctor Scripto

Summary: Learn how to use a regular expression pattern to remove non-alphabetic characters from a string by using Windows PowerShell.  How can I use Windows PowerShell to remove non-alphabetic characters from a string?  To remove nonalphabetic characters from a string, you can use the -Replace operator and substitute an empty string ‘’ for the nonalphabetic character. The secret to doing this is to create a pattern on characters that you want to include and then using the not (^) in the series symbol. Here is an example: $string = 'abcdefg12345HIJKLMNOP!@#$%qrs)(*&^TUVWXyz' $pattern = '[^a-zA-Z]' $string -re...

Apr 15, 2016
Post comments count 0
Post likes count 0

Additional resources for text analysis by using PowerShell

Doctor Scripto

Summary: This is a summary of some of the additional resources for working with text and Windows PowerShell. Good day. Microsoft Scripting Guy, Ed Wilson, is here. So, here's the deal. We are going along and decide to write a simple Windows PowerShell script. Before we know it, the thing has morphed into dozens of lines. And, also before we know it, we quickly find ourselves in the weeds. It begins like a day at the beach, perhaps like the one here. And suddenly, before we know it, we are in the weeds, look around and, lo and behold, alligators. Dude! And, all of a sudden, we are feeling as exposed as a bu...

Apr 14, 2016
Post comments count 0
Post likes count 0

Calculate percentage character frequencies from a text file by using PowerShell

Doctor Scripto

Summary: Learn how to use Windows PowerShell to calculate the percentage of how often a character appears in a text file. This is the fifth post in a multi-part series of blog posts that deal with how to determine letter frequency in text files. To fully understand this post, you should read the entire series in order. Here are the posts in the series: Okay, I will admit that I am just playing around, but I wanted to calculate the percentages of letter frequencies in a text file. For this example, I am using A Tale of Two Cities as a text file. You should refer to earlier blog articles about this ...

Apr 13, 2016
Post comments count 0
Post likes count 0

Compare the letter frequency of two text files by using PowerShell

Doctor Scripto

Summary: Learn how to use Windows PowerShell to compare the letter frequency of two different text files. This is the fourth post in a multi-part series of blog posts that deal with how to determine letter frequency in text files. To fully understand this post, you should read the entire series in order. Here are the posts in the series: One thing that is kind of cool is that with Windows PowerShell you can do all kinds of stuff and never have to write a script. This also means that it is easy to forget your scripting skills after a few years of never writing scripts. You may say, "WOOHOO!!!" But,...

Apr 12, 2016
Post comments count 0
Post likes count 0

Read a text file and do frequency analysis by using PowerShell

Doctor Scripto

Summary: Learn how to read a text file and do a letter-frequency analysis using Windows PowerShell in this article written by the Microsoft Scripting Guy, Ed Wilson. This is the third post in a multi-part series of blog posts that deal with how to determine letter frequency in text files. To fully understand this post, you should read the entire series in order. Here are the posts in the series: Today I am going to put the script I wrote yesterday together with the script that I wrote on Friday. After I do that, I will be able to get a more accurate letter-frequency analysis of a text file. The co...

Apr 11, 2016
Post comments count 0
Post likes count 1

How to skip the beginning and ending of a file by using PowerShell

I_am_mr_ed

Summary: Learn how to skip the beginning and ending portions of a text file by using Windows PowerShell in this article by the Microsoft Scripting Guy Ed Wilson. This is the second post in a multi-part series of blog posts that deal with how to determine letter frequency in text files. To fully understand this post, you should read the entire series in order. Here are the posts in the series: Good morning, Microsoft Scripting Guy Ed Wilson is here. At this very moment, the Scripting Wife (PowerShell MVP Teresa Wilson) and I are heading back to Central Florida after an absolutely incredible week in...

Apr 8, 2016
Post comments count 0
Post likes count 0

Letter frequency analysis of text by using PowerShell

Doctor Scripto

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to do letter frequency analysis of a text enabling one to see how often a letter occurs. This is the first post in a multi-part series of blog posts that deal with how to determine letter frequency in text files. To fully understand this post, you should read the entire series in order. Here are the posts in the series: So, the other night I was watching a show about cryptography. In the episode, the moderator said that all forms of encryption involve some form or type of letter substitution, and they went back over ...

Apr 6, 2016
Post comments count 0
Post likes count 0

PowerShell 5 MVA coming soon to a computer near you

I_am_mr_ed

SUMMARY: Microsoft Scripting Guy, Ed Wilson talks about recording a new Microsoft Virtual Academy series of videos with PFE Ashley McGlone. Hello everyone, Microsoft Scripting Guy Ed Wilson here. Well, I can tell you this week has been absolutely incredible. The Scripting Wife and I are out in Seattle (Bellevue, Redmond, Puget Sound ... whatever region) for the PowerShell Dev/Ops summit. This sold out event has been awesome ... and it is not over yet. With more than 150 PowerShellers from around the world, the electricity, the buzz, the overall awesomeness factor is rocking. Well, anyway, Microsoft PFE Ashley M...

Apr 5, 2016
Post comments count 0
Post likes count 1

PowerTip: Create a nested PowerShell custom object

Doctor Scripto

Summary: Learn how to create a nested PowerShell custom object.  How do I create a nested PowerShell custom object to store layers (nested) of information? Use a hashtable with the PSCustomObject type accelerator, and specify PSCustomObject as the value to the Property Name (Key): [PSCustomObject]@{ PropertyName = [PSCustomObject]@{ NestedPropertyName = ‘NestedPropertyValue’ } }