For many different scenarios, you need to create or generate a new GUID on Windows. With PowerShell, you can simply create and generate a new GUID on Windows, but also on Linux.
Create GUID using .NET
Before we had this cmdlet we had to use the .NET command to create a new GUID:
Create and generate GUID on Windows using PowerShell
PowerShell version 5 brings a lot of new cmdlets that make our lives easier and our code cleaner. One of them is the New-GUID cmdlet, which allows you to easily create a new GUID using PowerShell on Windows. Now with PowerShell 5 or higher, we can use simply the new cmdlet:
You can read more about the cmdlet here on Microsoft Docs.
Conclusion
I hope this does the trick for you and helps you with PowerShell going forward. Let me know in the comments if you have any questions. Also, check out my blog post on how to install and update PowerShell 7.
Tags:
create,
Generate,
GUID,
Microsoft,
PowerShell,
PowerShell 5,
Windows,
Windows 10,
Windows Server,
Windows Server 2016 Last modified: May 16, 2020
Thomas works as a Senior Cloud Advocate at Microsoft. He engages with the community and customers around the world to share his knowledge and collect feedback to improve the Azure cloud platform. Prior joining the Azure engineering team, Thomas was a Lead Architect and Microsoft MVP, to help architect, implement and promote Microsoft cloud technology.
If you want to know more about Thomas, check out his blog: www.thomasmaurer.ch and Twitter: www.twitter.com/thomasmaurer
January 19, 2021•
PowerShell
Many of you know the “timeout” command we used when we created Windows Batch scripts. This pauses/waits/sleeps the script for a...
Read More →
January 19, 2021•
Windows Server
• 2 Comments
If you are running a virtual machine (VM) on Hyper-V, sometimes you want to know on which Hyper-V host this VM is running. If you...
Read More →
January 15, 2021•
PowerShell
Windows has the concept of the recycle bin, from which you can restore files you have deleted. You might want to clear the Windows recycle...
Read More →
January 14, 2021•
Certification
As you know helping people get certified and help them with their careers is one part of my goals. So I want to share a very interesting...
Read More →