PowerShell drops the trailing zero of an array element's value when that value contains a dot. Unless I wrap the value in quotes. Unfortunately I need to retain the trailing zero and the script users fail to use quotes reliably.
How can I coerce PowerShell to preserve the trailing zero?
- The array element format is Number.Number
- The array element may have 1 to n trailing zeros
- Single element arrays retain trailing zeros
- Multi element arrays drop trailing zeros
Strongly typing the parameter as [string[]] does not resolve the issue.
Example:
function Get-Customer {
Param
(
[string[]]$CustomerId
)
$CustomerId
}
> Get-Customer -CustomerId 654.1,654.10,654.1721,654.1720
654.1 #CORRECT
654.1 #INVALID
654.1721 #CORRECT
654.172 #INVALID