How to convert to UInt64 from a string in Powershell? String-to-number conversion
问题 Consider the following Powershell snippet: [Uint64] $Memory = 1GB [string] $MemoryFromString = "1GB" [Uint64] $ConvertedMemory = [Convert]::ToUInt64($MemoryFromString) The 3rd Line fails with: Exception calling "ToUInt64" with "1" argument(s): "Input string was not in a correct format." At line:1 char:1 + [Uint64]$ConvertedMemory = [Convert]::ToUInt64($MemoryFromString) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [],