GUID V4 - Random-Based Identifier (Recommended)
GUID v4 is the most widely used random-based identifier. Learn about its structure, collision probability, advantages and why it is recommended for general-purpose applications.
Generate GUIDs in PowerShell with [System.Guid]::NewGuid() for random values and with [System.Guid]::CreateVersion7() when the shell runs on .NET 9 or newer.
[System.Guid]::NewGuid() for random GUIDs and only use GUID v7 when your PowerShell environment runs on a .NET version that supports it.$id = [System.Guid]::NewGuid()
$id$id = [System.Guid]::CreateVersion7()
$idThis requires .NET 9 or newer. In practice that means PowerShell 7.5+ can call the API, while Windows PowerShell 5.1 cannot.
System.Guid type.[System.Guid]::CreateVersion7() requires .NET 9 or newer. That makes it available in PowerShell 7.5+ and unavailable in Windows PowerShell 5.1.These articles expand on related concepts, formats and practical considerations.