How to Convert a String to an Integer in PowerShell (and Decimal, Double)
To convert a string to an integer in PowerShell, cast it with [int]. After that, math works as numbers instead of text: Output: Use [decimal] for money and [double] for other fractions. Below I cover safe conversion, rounding, commas, characters and scientific notation. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1, with … Read more