Skip to content

Commit 5f757e9

Browse files
Document New-Guid UUID v7 default change for PowerShell 7.7
1 parent 3be8458 commit 5f757e9

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

reference/7.7/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: 05/11/2026
66
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-guid?view=powershell-7.7&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-77.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ PowerShell 7.7 includes the following updated modules:
2020

2121
## Breaking Changes
2222

23+
- `New-Guid` now generates Version 7 (time-sortable) UUIDs by default instead of Version 4
24+
(random). The output format is unchanged. Scripts that depend on fully random GUIDs should use
25+
`[guid]::NewGuid()` directly. ([#27033][27033])
2326
- Add `ValidateNotNullOrEmpty` attribute to the `-Property` of `Format-Table`, `Format-List`, and
2427
`Format-Custom` ([#26552][26552])
2528
- Use ArgumentException.ThrowIfNullOrEmpty for not-null-not-empty argument validation.
@@ -36,6 +39,8 @@ PowerShell 7.7 includes the following updated modules:
3639

3740
## Cmdlet improvements
3841

42+
- Change `New-Guid` to generate UUID v7 by default using `Guid.CreateVersion7()`
43+
([#27033][27033])
3944
- Correct handling of explicit `-<SwitchParameter>:$false` parameter values for the following
4045
cmdlets:
4146
- `ConvertFrom-Csv`, `ConvertTo-Csv`, `Export-Csv`, and `Import-Csv` ([#26719][26719]) (Thanks
@@ -153,5 +158,6 @@ PowerShell 7.7 includes the following experimental features.
153158
[27095]: https://github.com/PowerShell/PowerShell/pull/27095
154159
[27106]: https://github.com/PowerShell/PowerShell/pull/27106
155160
[27109]: https://github.com/PowerShell/PowerShell/pull/27109
161+
[27033]: https://github.com/PowerShell/PowerShell/pull/27033
156162
[27123]: https://github.com/PowerShell/PowerShell/pull/27123
157163
[27266]: https://github.com/PowerShell/PowerShell/pull/27266

0 commit comments

Comments
 (0)