mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Correct handling of explicit -Empty:$false parameter value in New-Guid (#26140)
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
else
|
||||
{
|
||||
guid = ParameterSetName is "Empty" ? Guid.Empty : Guid.NewGuid();
|
||||
guid = Empty.ToBool() ? Guid.Empty : Guid.NewGuid();
|
||||
}
|
||||
|
||||
WriteObject(guid);
|
||||
|
||||
@@ -17,6 +17,11 @@ Describe "New-Guid" -Tags "CI" {
|
||||
$guid.ToString() | Should -BeExactly "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
|
||||
It "Should respect explicit false value for -Empty" {
|
||||
$guid = New-Guid -Empty:$false
|
||||
$guid.ToString() | Should -Not -BeExactly "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
|
||||
It "Should convert a string to a guid" {
|
||||
$guid1 = New-Guid
|
||||
$guid2 = New-Guid -InputObject $guid1.ToString()
|
||||
|
||||
Reference in New Issue
Block a user