| description | Invalid version construction |
|---|---|
| ms.date | 04/24/2024 |
| ms.topic | reference |
| title | InvalidMultiDotValue |
Severity Level: Error
PowerShell does not support an implicit value with multiple dots.
Any unquoted value with 2 or more dots will not be treated as any special type (like a version or IPAddress)
but result in $null. These objects need to be constructed from either a quoted string (e.g. [Version]'1.2.3')
or their individual components (e.g. [Version]::new(1, 2, 3)).
$version = 1.2.3or even:
$IP = [System.Net.IPAddress]127.0.0.1Where both examples will result in $null instead of any specific object.
$version = [Version]'1.2.3'
# or:
$version = [Version]::new(1, 2, 3)$IP = [System.Net.IPAddress]'127.0.0.1'