22external help file : Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Utility
5- ms.date : 01/24/2024
5+ ms.date : 03/26/2026
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/new-guid?view=powershell-7.6&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : New-Guid
@@ -34,8 +34,15 @@ 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 (time-sortable) globally unique identifier (GUID). If you
38+ need a unique ID in a script, you can create a GUID, as needed. Version 7 UUIDs contain a
39+ millisecond-precision timestamp and are monotonically sortable, making them ideal for database keys
40+ and distributed systems.
41+
42+ > [ !NOTE]
43+ > In PowerShell 7.5 and earlier, ` New-Guid ` created Version 4 (random) UUIDs. Starting in
44+ > PowerShell 7.6, the default changed to Version 7. If you need a Version 4 UUID, use
45+ > ` [guid]::NewGuid() ` directly.
3946
4047## EXAMPLES
4148
@@ -46,7 +53,8 @@ New-Guid
4653```
4754
4855This command creates a random GUID. Alternatively, you could store the output of this cmdlet in a
49- variable to use elsewhere in a script.
56+ variable to use elsewhere in a script. Starting in PowerShell 7.6, ` New-Guid ` generates Version 7
57+ UUIDs by default.
5058
5159### Example 2: Create an empty GUID
5260
9510301234567-89ab-cdef-0123-456789abcdef
96104```
97105
106+ ### Example 5: Create specific UUID versions using .NET APIs
107+
108+ This example shows how to create specific UUID versions using the underlying .NET APIs directly.
109+
110+ ``` powershell
111+ # Create a Version 7 UUID (same as New-Guid default in PowerShell 7.6+)
112+ [guid]::CreateVersion7()
113+
114+ # Create a Version 4 UUID (default in PowerShell 7.5 and earlier)
115+ [guid]::NewGuid()
116+ ```
117+
98118## PARAMETERS
99119
100120### -Empty
@@ -150,8 +170,17 @@ The cmdlet passes string input to the constructor of the **System.Guid** class.
150170support strings in several formats. For more information, see
151171[System.Guid(String)](/dotnet/api/system.guid.-ctor#system-guid-ctor(system-string)).
152172
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).
173+ When used without string input or the **Empty** parameter, the cmdlet creates a Version 7
174+ Universally Unique Identifier (UUID) as defined in
175+ [RFC 9562](https://www.rfc-editor.org/rfc/rfc9562). Version 7 UUIDs contain a
176+ millisecond-precision timestamp and are monotonically sortable, making them ideal for database keys
177+ and distributed systems.
178+
179+ In previous versions of PowerShell, the cmdlet created a Version 4 (random) UUID. If you need a
180+ Version 4 UUID, use ` [guid]::NewGuid()`. To explicitly create a Version 7 UUID, use
181+ ` [guid]::CreateVersion7()` .
182+
183+ For more information, see
184+ [System.Guid.CreateVersion7](xref:System.Guid.CreateVersion7).
156185
157186# # RELATED LINKS
0 commit comments