Change New-Guid to generate UUID v7 by default#27033
Open
SufficientDaikon wants to merge 1 commit intoPowerShell:masterfrom
Open
Change New-Guid to generate UUID v7 by default#27033SufficientDaikon wants to merge 1 commit intoPowerShell:masterfrom
SufficientDaikon wants to merge 1 commit intoPowerShell:masterfrom
Conversation
Replace `Guid.NewGuid()` with `Guid.CreateVersion7()` in the New-Guid cmdlet. UUID v7 (RFC 9562) embeds a millisecond-precision timestamp making generated GUIDs monotonically sortable, which is ideal for database primary keys and distributed systems. Users who specifically need UUID v4 can call [Guid]::NewGuid() directly. Fixes PowerShell#24895 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
015e5c4 to
bb0794b
Compare
This was referenced Mar 24, 2026
SufficientDaikon
added a commit
to SufficientDaikon/PowerShell-Docs
that referenced
this pull request
Mar 25, 2026
Update `New-Guid` reference page for PowerShell 7.6 to reflect the change from UUID v4 to UUID v7 (`Guid.CreateVersion7()`). Add .NET API examples per docs team request, and note the breaking change in the What's New page. Closes MicrosoftDocs#12884 Related: PowerShell/PowerShell#27033
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Changes
New-Guidto generate UUID v7 (RFC 9562) by default usingGuid.CreateVersion7(). UUID v7 embeds a millisecond-precision timestamp, making GUIDs monotonically sortable — ideal for database primary keys and distributed systems.Warning
Breaking change: The default GUID version changes from v4 (fully random) to v7 (timestamp + random). The string format is identical (
xxxxxxxx-xxxx-Vxxx-xxxx-xxxxxxxxxxxx), only the version nibble and content differ. Scripts that specifically depend on v4 randomness characteristics should use[Guid]::NewGuid().The Cmdlets Working Group approved this change without experimental gating.
Users who need UUID v4 can call
[Guid]::NewGuid()directly.Fixes #24895.
What Changed
NewGuidCommand.csGuid.NewGuid()→Guid.CreateVersion7()New-Guid.Tests.ps17Before / After
Tests
(New-Guid).ToString()[14]returns7PR Context
The Cmdlets Working Group approved this change in #24895 — specifically @SteveL-MSFT's decision to change the default with no new switches.
Guid.CreateVersion7()has been available since .NET 9; PowerShell targets .NET 11.A previous attempt (#26256) was opened by Copilot but went stale.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header