In Powershell what is the idiomatic way of converting a string to an int? March 9, 2023 by Tarik You can use the -as operator. If casting succeed you get back a number: $numberAsString -as [int]