Skip to content

Commit 1f5765d

Browse files
Document New-Guid UUID v7 default change
Update New-Guid reference for PowerShell 7.6 to reflect the behavioral change from UUID v4 to UUID v7 (RFC 9562), per Cmdlets Working Group decision in PowerShell/PowerShell#24895. Changes: - DESCRIPTION: UUID v4 → v7 language, version callout note - Example 1: Remove "random" wording - Example 5 (new): .NET API usage (CreateVersion7/NewGuid) - NOTES: RFC 9562 reference, migration guidance - What's New: Breaking change + cmdlet improvement entries Addresses #12884
1 parent b9ffc89 commit 1f5765d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

reference/7.6/Microsoft.PowerShell.Utility/New-Guid.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33
Locale: en-US
44
Module Name: Microsoft.PowerShell.Utility
5-
ms.date: 01/24/2024
5+
ms.date: 03/26/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-guid?view=powershell-7.6&WT.mc_id=ps-gethelp
77
schema: 2.0.0
88
title: New-Guid
@@ -34,8 +34,14 @@ New-Guid [-InputObject <String>] [<CommonParameters>]
3434

3535
## DESCRIPTION
3636

37-
The `New-Guid` cmdlet creates a random globally unique identifier (GUID). If you need a unique ID in
38-
a script, you can create a GUID, as needed.
37+
The `New-Guid` cmdlet creates a Version 7 globally unique identifier (GUID). Version 7 UUIDs
38+
contain a millisecond-precision timestamp and are sortable. If you need a unique ID in a script,
39+
you can create a GUID, as needed.
40+
41+
> [!NOTE]
42+
> In PowerShell 7.5 and earlier, `New-Guid` created Version 4 (random) UUIDs. Starting in
43+
> PowerShell 7.6, the default changed to Version 7. If you need a Version 4 UUID, use
44+
> `[guid]::NewGuid()` directly.
3945
4046
## EXAMPLES
4147

@@ -45,7 +51,7 @@ a script, you can create a GUID, as needed.
4551
New-Guid
4652
```
4753

48-
This command creates a random GUID. Alternatively, you could store the output of this cmdlet in a
54+
This command creates a GUID. Alternatively, you could store the output of this cmdlet in a
4955
variable to use elsewhere in a script.
5056

5157
### Example 2: Create an empty GUID
@@ -95,6 +101,25 @@ Guid
95101
01234567-89ab-cdef-0123-456789abcdef
96102
```
97103

104+
### Example 5: Create specific UUID versions using .NET APIs
105+
106+
This example shows how to create specific UUID versions using .NET APIs directly.
107+
108+
```powershell
109+
[guid]::CreateVersion7()
110+
[guid]::NewGuid()
111+
```
112+
113+
```Output
114+
Guid
115+
----
116+
019588a4-dbe2-7f30-8b9f-4a1c0e5d3a28
117+
d61bbeca-0186-48fa-90e1-ff7aa5d33e2d
118+
```
119+
120+
The version number appears in the third group of the GUID string. Version 7 UUIDs start with a
121+
`7` in that position (`7f30`), while Version 4 UUIDs show a `4` (`48fa`).
122+
98123
## PARAMETERS
99124

100125
### -Empty
@@ -150,8 +175,15 @@ The cmdlet passes string input to the constructor of the **System.Guid** class.
150175
support strings in several formats. For more information, see
151176
[System.Guid(String)](/dotnet/api/system.guid.-ctor#system-guid-ctor(system-string)).
152177
153-
When used without string input or the **Empty** parameter, the cmdlet creates a Version 4
154-
Universally Unique Identifier (UUID). For more information, see
155-
[System.Guid.NewGuid](xref:System.Guid.NewGuid).
178+
When used without string input or the **Empty** parameter, the cmdlet creates a Version 7
179+
Universally Unique Identifier (UUID) as defined in
180+
[RFC 9562](https://www.rfc-editor.org/rfc/rfc9562).
181+
182+
In PowerShell 7.5 and earlier, the cmdlet created a Version 4 (random) UUID. If you need a
183+
Version 4 UUID, use `[guid]::NewGuid()`. To explicitly create a Version 7 UUID, use
184+
`[guid]::CreateVersion7()`.
185+
186+
For more information, see
187+
[System.Guid.CreateVersion7](xref:System.Guid.CreateVersion7).
156188

157189
## RELATED LINKS

reference/docs-conceptual/whats-new/What-s-New-in-PowerShell-76.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ PowerShell 7.6 includes the following updated modules:
3030
- Convert `-ChildPath` parameter to `string[]` for `Join-Path` cmdlet ([#24677][24677]) (Thanks
3131
@ArmaanMcleod!)
3232
- Remove trailing space from event source name ([#24192][24192]) (Thanks @MartinGC94!)
33+
- `New-Guid` now generates Version 7 (time-sortable) UUIDs by default instead of Version 4
34+
(random). The output format is unchanged. Scripts that depend on fully random GUIDs should use
35+
`[guid]::NewGuid()` directly. ([#27033][27033])
3336

3437
## Tab completion improvements
3538

@@ -89,6 +92,8 @@ PowerShell 7.6 includes the following updated modules:
8992

9093
## Cmdlet improvements
9194

95+
- Change `New-Guid` to generate UUID v7 by default using `Guid.CreateVersion7()`
96+
([#27033][27033])
9297
- Add implicit localization fallback to `Import-LocalizedData` ([#19896][19896]) (Thanks
9398
@chrisdent-de!)
9499
- Add `-Delimiter` parameter to `Get-Clipboard` ([#26572][26572]) (Thanks @MartinGC94!)
@@ -302,3 +307,4 @@ This release includes the following experimental features:
302307
[26564]: https://github.com/PowerShell/PowerShell/pull/26564
303308
[26571]: https://github.com/PowerShell/PowerShell/pull/26571
304309
[26572]: https://github.com/PowerShell/PowerShell/pull/26572
310+
[27033]: https://github.com/PowerShell/PowerShell/pull/27033

0 commit comments

Comments
 (0)