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,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.
4551New-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
4955variable to use elsewhere in a script.
5056
5157### Example 2: Create an empty GUID
9510101234567-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.
150175support 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
0 commit comments