Converting VBScript's CInt Function
Definition: Returns an expression that has been converted to a Variant of subtype Integer.
Need to convert a value to the integer data type? No problem: not only will Windows PowerShell make the conversion for you, but it will also round the value off to the nearest whole number. (Some languages convert a value to an integer simply by stripping off the decimal point.) The following two commands assign a string value to the variable $a, then convert the data type of $a to integer:
$a = "11.57" $a = [int] $a
When you run these two commands and then echo back the value of $a you should get the following:
And if you run the GetType() method against $a you’ll see it now has the following data type:
IsPublic IsSerial Name -------- -------- ---- True True Int32