Skip to content
Follow
Windows 🟡 Intermediate

Generate a New GUID in Windows 11 with PowerShell

Richard
Written by
Richard
Oct 11, 2026 9 min read
Windows 11 desktop with a PowerShell window open, illustrating how to generate a new GUID with PowerShell.
Windows 11 desktop with a PowerShell window open, illustrating how to generate a new GUID with PowerShell.

Running New-Guid in PowerShell prints a new GUID (globally unique identifier) in a few milliseconds. You do not need administrator rights to do it. This works in Windows PowerShell 5.1, which comes with Windows 11, and in PowerShell 7.

Advertisement

A GUID is a 128-bit value, which is a very large binary number. It is written as 32 hexadecimal digits in five groups separated by hyphens, such as 0f8fad5b-d9cb-469f-a165-70867728950e.

Developers and administrators use GUIDs as unique labels for database rows, installer product codes, config files, and test data. The chance of making the same GUID twice is so small that you can use a new one without checking for copies.

⚡ Quick Answer

Run New-Guid in PowerShell to generate a new GUID (globally unique identifier) in Windows 11. No administrator rights are needed, and the command works in both Windows PowerShell 5.1 and PowerShell 7. To print only the value with no heading, run (New-Guid).Guid. To copy it straight to the clipboard, run (New-Guid).Guid | Set-Clipboard.

Advertisement

Before You Start

📝Good to KnowEverything in this guide runs as a standard user.

No step needs an elevated (administrator) window. The one exception is installing PowerShell 7 in the optional section further down, which may show a User Account Control prompt.

Windows 11 includes two versions of PowerShell, and the difference matters for a few options below:

  • Windows PowerShell 5.1 is built into Windows 11. It is the one you get when you search for “PowerShell” in the Start menu .
  • PowerShell 7 is a separate, newer release you install yourself. It runs side by side with 5.1 and does not replace it.

The basic New-Guid command works the same in both. The -Empty parameter and a few other extras need PowerShell 7. The article flags each of these where it comes up.

Advertisement

Generate a New GUID with New-Guid

These steps open PowerShell and generate one GUID. New-Guid is a cmdlet (a built-in PowerShell command) from the Microsoft.PowerShell.Utility module, and it needs no setup or imports.

  1. Select Start and type PowerShell.
  2. Select Windows PowerShell in the results. A PowerShell window opens with a prompt that starts with PS, followed by your user folder, such as PS C:\Users\USERNAME>.
  3. Type the following command and press Enter:
    💻Code
    New-Guid
  4. Read the result. PowerShell prints a column headed Guid with your new value underneath:
    💻Code
    Guid
    ----
    0f8fad5b-d9cb-469f-a165-70867728950e

    Your GUID is different from this example. That is expected, because every run produces a new random value.

  5. Press the Up arrow key and then Enter to run the command again and get another GUID.

You can also open PowerShell by right-clicking Start and selecting Terminal (labelled Windows Terminal on earlier Windows 11 builds). Terminal opens PowerShell by default on current builds, but a profile may have been changed to Command Prompt. If your prompt does not start with PS, see the troubleshooting section below.

Get Only the GUID as Plain Text

The default output is an object with a Guid property, which is why you see a heading and a dashed line. That is fine for reading, but if you want to paste the value or pass it to another command, you need it as plain text.

Advertisement

Return the GUID as a string

Wrap the command in parentheses and read its Guid property. This prints only the value, with no heading:

💻Code
(New-Guid).Guid

You should now see a single line, for example 0f8fad5b-d9cb-469f-a165-70867728950e. The result is a string, so you can store it in a variable:

⬛PowerShell
$id = (New-Guid).Guid

Type $id and press Enter to print the stored value. The variable lasts until you close the window.

Copy the GUID to the clipboard

Send the string to Set-Clipboard to skip selecting and copying text by hand:

Advertisement
💻Code
(New-Guid).Guid | Set-Clipboard

Nothing prints, because the value goes straight to the clipboard. Press Ctrl+V in any app to paste it. The Set-Clipboard cmdlet is available in both Windows PowerShell 5.1 and PowerShell 7.

Change the GUID Format

The default format has lowercase letters and hyphens. Some tools expect no hyphens, braces, or uppercase. A GUID object has a ToString() method that takes a one-letter format code, so you can change the layout without editing the text by hand.

Use this pattern, replacing N with the code you need:

💻Code
(New-Guid).ToString("N")
CodeWhat you get
D32 digits separated by hyphens. This is the default format.
N32 digits with no hyphens.
BThe hyphenated format inside braces.
PThe hyphenated format inside parentheses.
XFour hexadecimal values inside braces, with a nested set for the last eight bytes. This is the layout used in some C and C++ code.

The format codes control punctuation only. They do not change the letter case. To get uppercase letters, add .ToUpper() to the end:

Advertisement
💻Code
(New-Guid).ToString("B").ToUpper()

This prints a braced, uppercase GUID such as {0F8FAD5B-D9CB-469F-A165-70867728950E}. Use this form when a tool or config file asks for a GUID "in registry format". If you are unsure what the target expects, check its documentation. Many parsers accept both cases, but some compare text exactly.

Generate Several GUIDs at Once

You often need a batch of identifiers, for example to seed test data. Pipe (send) a range of numbers into the command, and PowerShell runs it once per number. ForEach-Object, and PowerShell runs New-Guid once per number.

  1. Click inside the PowerShell window.
  2. Type the following command and press Enter. Change 10 to the number of GUIDs you want:
    💻Code
    1..10 | ForEach-Object { (New-Guid).Guid }
  3. Check the output. You should see ten separate lines, each a different GUID.

Save the batch to a text file

To keep the list, send it to a file instead of the screen. This command writes the GUIDs to a file named guids.txt in your Documents folder:

💻Code
1..10 | ForEach-Object { (New-Guid).Guid } | Set-Content "$HOME\Documents\guids.txt"
⚠️WarningIf a file with that name already exists, Set-Content overwrites it without asking.

Change the file name if you want to keep the old one. Open File Explorer and go to Documents to find the new file. Each line holds one GUID.

Advertisement

Create an Empty GUID

An empty GUID is a value made entirely of zeros: 00000000-0000-0000-0000-000000000000. Developers use it as a placeholder meaning "no ID assigned yet". The method depends on your PowerShell version.

In PowerShell 7

Add the -Empty parameter:

💻Code
New-Guid -Empty

In Windows PowerShell 5.1

The built-in 5.1 version of New-Guid does not offer -Empty, and the command fails with an error about a missing parameter. Read the value from the .NET Guid type instead. This works in every version:

💻Code
[guid]::Empty

Use [guid]::NewGuid() Instead

PowerShell can call the .NET Guid class (a shared library of code that PowerShell draws on) directly. The result is the same kind of random GUID that New-Guid produces:

Advertisement
💻Code
[guid]::NewGuid()

Use this form if you are working with older scripts or an older PowerShell release that does not have New-Guid. It also returns a Guid object, so the .ToString("N") format codes and the .Guid trick apply to it the same way. For example, [guid]::NewGuid().ToString("N") prints a 32-digit GUID with no hyphens.

Check Whether a String Is a Valid GUID

If you have text from a file or an email and want to confirm it is a well-formed GUID, use TryParse. Replace the sample value with your own:

💻Code
[guid]::TryParse("0f8fad5b-d9cb-469f-a165-70867728950e", [ref][guid]::Empty)

PowerShell prints True if the text is a valid GUID and False if it is not. The check looks at format only. It cannot tell you whether the GUID belongs to anything on your computer.

Check Which PowerShell Version You Are Running

If a parameter is missing or a command behaves differently from this guide, check your version first. Run:

⬛PowerShell
$PSVersionTable.PSVersion

A major version of 5 means Windows PowerShell 5.1. A major version of 7 means PowerShell 7. The prompt does not tell you which one you are in, so this command is the reliable check.

Install PowerShell 7 (optional)

You need PowerShell 7 only for options that 5.1 lacks, such as -Empty. This step installs software and may prompt for administrator approval. Installing it does not remove or change Windows PowerShell 5.1.

  1. Open Terminal or Windows PowerShell.
  2. Run the following command:
    💻Code
    winget install Microsoft.PowerShell
  3. Approve the User Account Control prompt if one appears. Windows Package Manager (winget) downloads and installs the latest stable release.
  4. Select Start, type pwsh, and select PowerShell 7 to open it.

If winget reports that it cannot find the package, update App Installer from the Microsoft Store and try again.

Time-ordered GUIDs in PowerShell 7.5 and later

New-Guid produces fully random GUIDs. Some databases work better with GUIDs that sort by creation time. These are called version 7 GUIDs. PowerShell 7.5 and later run on a .NET release that supports them. In those versions, run:

💻Code
[guid]::CreateVersion7()

This method does not exist in Windows PowerShell 5.1, and the command returns an error there. Use New-Guid if you do not specifically need time-ordered values.

Troubleshooting

"New-Guid is not recognized as the name of a cmdlet"

You are most likely in Command Prompt, not PowerShell. Command Prompt shows a prompt like C:\Users\USERNAME> with no PS at the start. Type powershell and press Enter to switch into PowerShell. Alternatively, run a single command from Command Prompt without switching:

💻Code
powershell -Command "(New-Guid).Guid"

If you are in PowerShell and still see the error, check the spelling. The command has a hyphen and no space: New-Guid, not NewGuid or New Guid.

"A parameter cannot be found that matches parameter name 'Empty'"

You are in Windows PowerShell 5.1, which does not have -Empty. Use [guid]::Empty instead, or install PowerShell 7 as described above.

The GUID has braces or is missing hyphens

A format code was applied, or the value was copied from another tool. Run (New-Guid).Guid for the standard hyphenated, lowercase format with no braces.

Pasted text includes the Guid heading and dashes

You copied the table output from the screen. Use (New-Guid).Guid | Set-Clipboard so only the value reaches the clipboard.

What to Do Next

GUIDs you generate are not stored anywhere, so there is nothing to undo or clean up. Close the window and the variables you created disappear with it. If you want a one-word shortcut, add a small function that wraps (New-Guid).Guid | Set-Clipboard to your PowerShell profile, which loads each time you open a window. To change what New-Guid accepts on your system, run Get-Help New-Guid -Full, which lists the parameters available in your installed version.

What is a GUID in Windows?

A GUID (globally unique identifier) is a 128-bit number written as 32 hexadecimal digits in five groups separated by hyphens, such as 0f8fad5b-d9cb-469f-a165-70867728950e. Windows and developers use GUIDs as unique labels for things like database rows, installers, and config files, because two GUIDs almost never match.

What is the PowerShell command?

Type New-Guid at the PowerShell prompt and press Enter. It prints a new GUID each time you run it, and you do not need administrator rights. The command works in Windows PowerShell 5.1, which is built into Windows 11, and in PowerShell 7.

Is a GUID the same as a UUID?

Yes, for practical purposes they are the same thing. UUID (Universally Unique Identifier) is the name used in the IETF standard RFC 9562. Microsoft calls the same 128-bit format a GUID, and both use the same 32-digit, hyphen-separated layout, so a value from one works in the other.

What version of PowerShell is on 🪟 Windows 11?

Windows 11 includes Windows PowerShell 5.1 as its built-in version. Search for PowerShell in the Start menu to open it. PowerShell 7 is a newer, separate release that you install yourself, and it can run alongside the built-in version. Both work for the commands in this guide.

Was this guide helpful?

Tags: #Windows 11
Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

Sign In Another Way on Windows 11 Lock Screen
Windows Sign In Another Way on Windows 11 Lock Screen
How to Enable or Disable Import Browser Data from Microsoft Edge in Copilot
Windows How to Enable or Disable Import Browser Data from Microsoft Edge in Copilot
How to Export All Copilot Activity History for Microsoft Account
Windows How to Export All Copilot Activity History for Microsoft Account
Set Up a Windows Hello PIN In Windows 11
Windows Set Up a Windows Hello PIN In Windows 11

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *