jondwaite / CIVMDisks

PowerShell cmdlets to manage disks attached to Virtual Machines in VMware Cloud Director
MIT License
4 stars 3 forks source link

Get-APIVersion number format issue with non US English cultures #4

Open anttiah opened 1 year ago

anttiah commented 1 year ago

When running on culture other than US English, the non-exported function Get-APIVersion might return version in wrong format, which causes other functions to fail.

https://github.com/jondwaite/CIVMDisks/blob/master/CIVMDisks.psm1#L37

Example from a system using fi-FI culture. Note how decimal separator is replaced with comma.

C:\ [DBG]:>> $APIVersion = (($Versions.SupportedVersions.VersionInfo | `
>>             Where-Object { $_.deprecated -eq $false }) | `
>>             Measure-Object -Property Version -Maximum).Maximum.ToString()
C:\ [DBG]:>> $apiversion
36,3

This happens because Measure-Object -Maximum causes input to be parsed as a number and ToString() formats number according to user's current culture if no other formatting information is provided.