Scripting Blog [archived]

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

Rounding Numbers—PowerShell Style

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to round numbers. (image)  Hey, Scripting Guy! I think your series about formatting numbers has been pretty interesting. However, everything you have shown has a major problem—and that is that you convert numbers into strings. I would love to be ...

PowerTip: Express Percentage in PowerShell

Summary: Learn an easy method to express a percentage in Windows PowerShell. (image)  How can I use Windows PowerShell to express a two-decimal place percentage? For example, I have multiple            calculations in a Windows PowerShell script, and I am tired of always dividing two numbers, multiplying &...

PowerTip: Round a Number with PowerShell

Summary: Use Windows PowerShell to round numbers to a specific decimal place. (image)  How can I use Windows PowerShell to round a number to a specific number of decimal places, and continue to            have a number instead of converting it to a string. (image)  Use the Round static method ...

PowerTip: Format Decimal Numbers in PowerShell

Summary: Learn how to display a specific number of decimal points in Windows PowerShell. (image)  How can I use Windows PowerShell to display only one decimal place on a number that currently has two? (image)  Use a custom number format string with the ToString method from the number, for example: PS C:\> (1.11).tostring...