Skip to content

Commit f698527

Browse files
Fix redundancy, add example output, remove editorial language
- Remove "ideal for database keys" editorial from DESCRIPTION and NOTES - Fix Example 1 contradiction: said "random" after changing cmdlet to v7 - Remove redundant v7 sentence from Example 1 (already covered in DESCRIPTION) - Add Output block to Example 5 showing v4 vs v7 version nibble difference - Use specific "PowerShell 7.5 and earlier" in NOTES instead of vague phrasing - Keep DESCRIPTION and NOTES complementary, not duplicative
1 parent 6421b44 commit f698527

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ New-Guid [-InputObject <String>] [<CommonParameters>]
3434

3535
## DESCRIPTION
3636

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.
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.
4140

4241
> [!NOTE]
4342
> In PowerShell 7.5 and earlier, `New-Guid` created Version 4 (random) UUIDs. Starting in
@@ -52,9 +51,8 @@ and distributed systems.
5251
New-Guid
5352
```
5453

55-
This command creates a random GUID. Alternatively, you could store the output of this cmdlet in a
56-
variable to use elsewhere in a script. Starting in PowerShell 7.6, `New-Guid` generates Version 7
57-
UUIDs by default.
54+
This command creates a GUID. Alternatively, you could store the output of this cmdlet in a
55+
variable to use elsewhere in a script.
5856

5957
### Example 2: Create an empty GUID
6058

@@ -105,16 +103,23 @@ Guid
105103

106104
### Example 5: Create specific UUID versions using .NET APIs
107105

108-
This example shows how to create specific UUID versions using the underlying .NET APIs directly.
106+
This example shows how to create specific UUID versions using .NET APIs directly.
109107

110108
```powershell
111-
# Create a Version 7 UUID (same as New-Guid default in PowerShell 7.6+)
112109
[guid]::CreateVersion7()
113-
114-
# Create a Version 4 UUID (default in PowerShell 7.5 and earlier)
115110
[guid]::NewGuid()
116111
```
117112

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+
118123
## PARAMETERS
119124

120125
### -Empty
@@ -172,11 +177,9 @@ support strings in several formats. For more information, see
172177
173178
When used without string input or the **Empty** parameter, the cmdlet creates a Version 7
174179
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.
180+
[RFC 9562](https://www.rfc-editor.org/rfc/rfc9562).
178181
179-
In previous versions of PowerShell, the cmdlet created a Version 4 (random) UUID. If you need a
182+
In PowerShell 7.5 and earlier, the cmdlet created a Version 4 (random) UUID. If you need a
180183
Version 4 UUID, use `[guid]::NewGuid()`. To explicitly create a Version 7 UUID, use
181184
`[guid]::CreateVersion7()`.
182185

0 commit comments

Comments
 (0)