Scripting Blog [archived]

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

PowerTip: Use PowerShell to display a percentage that has two decimal places

Summary: Use Windows PowerShell to display a percentage as a two place number. (image)  How can I use Windows PowerShell to display a number as a percentage that has two decimal places? (image)  Use the -f format specifier, and specify a pattern as “{0:p2}”. On the other side of the -f format specifier, perform your percentage ...

Calculate percentage character frequencies from a text file by using PowerShell

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 ...

PowerTip: Return remainder after dividing two numbers

Summary: Use Windows PowerShell to return the remainder after dividing two numbers. (image)  How can use Windows PowerShell to divide two numbers and only return the remainder (called a modulo operation)? (image)  In Windows PowerShell, the modulo operator is the % sign. Here are a few examples of how to use ...

Weekend Scripter: Approximate the Value of Pi from a Polygon

Summary: Microsoft senior software engineer, Firaz Samet, shows how to use Windows PowerShell to approximate the value of pi from a polygon. Microsoft Scripting Guy, Ed Wilson, is here. Today we have a guest blog post from Firaz Samet in honor of Pi (π) Day. I will turn the blog over… The Scripting Guy ran across my PowerShell Math ...

Weekend Scripter: PowerShell Does Scientific Notation

Summary: Microsoft PFE and guest blogger, Clint Huffman, talks about scientific notation and Windows PowerShell. Microsoft Scripting Guy, Ed Wilson, is here. Today we have another guest blogger from the past—Clint Huffman. The keyboard is yours Clint… In Performance Monitor, if a number in a field is too large to display, ...