In PowerShell, how can I test if a variable holds a numeric value?
Currently, I\'m trying to do it like this, but it always seems to return false.
false
filter isNumeric { $_ -is [ValueType] }
-
1 -is [ValueType] True "1" -is [ValueType] False
function isNumeric ($Value) { return $Value -is [ValueType] } isNumeric 1.23 True isNumeric 123 True isNumeric "" False isNumeric "asdf123" False
(Invoke-Expression '1.5') -is [ValueType]