Skip to content

Commit 6f7ffc2

Browse files
SufficientDaikonclaudejshigetomi
authored
Change New-Guid to generate UUID v7 by default (#27033)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Justin Chung <124807742+jshigetomi@users.noreply.github.com>
1 parent 7d596de commit 6f7ffc2

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/Microsoft.PowerShell.Commands.Utility/commands/utility/NewGuidCommand.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected override void ProcessRecord()
4949
}
5050
else
5151
{
52-
guid = Empty.ToBool() ? Guid.Empty : Guid.NewGuid();
52+
guid = Empty.ToBool() ? Guid.Empty : Guid.CreateVersion7();
5353
}
5454

5555
WriteObject(guid);

‎test/powershell/Modules/Microsoft.PowerShell.Utility/New-Guid.Tests.ps1‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Describe "New-Guid" -Tags "CI" {
4343
$observed | Should -Be $guids
4444
}
4545

46+
It "Should generate a UUID v7" {
47+
$guid = New-Guid
48+
# UUID v7 has version nibble '7' at position 14 in the string representation
49+
$guid.ToString()[14] | Should -BeExactly '7'
50+
}
51+
4652
It "Should return different guids with each call" {
4753
$guid1 = New-Guid
4854
$guid2 = New-Guid

0 commit comments

Comments
 (0)