With the recent Thanksgiving Holiday, I thought it would be a good time to share a trick that will provide a feast of GUIDS. I like to use this method while doing SharePoint development, but it can really be useful anytime you have a need to create several GUIDs. While it is easy to create a random GUID through the GUID Generator packaged with Visual Studio, or do so through code, I often find myself needing to create many GUIDs at once, so I created this trick to keep a fresh slab of GUIDs at the ready for when the time calls.
This is a PowerShell script that will allow you to create a multitude of GUIDs and save them to a file for later use. It is a quick one-liner, although I have divided it into multiple lines here for readability. I like to simply remove GUIDs from the top as I use them, to ensure I don’t duplicate one throughout my development.
@(for($i=0; $i -lt 100; $i++) { [System.Guid]::NewGuid().ToString("B") }) > "C:\Guids.txt"
When outputting the GUIDs, you may need a specific format. Here is a helpful list: (Source: http://msdn.microsoft.com/en-us/library/97af8hh4.aspx)
| Format | Output |
| (Empty) | 00000000-0000-0000-0000-000000000000 |
| N | 00000000000000000000000000000000 |
| D | 00000000-0000-0000-0000-000000000000 |
| B | {00000000-0000-0000-0000-000000000000} |
| P | (00000000-0000-0000-0000-000000000000) |
| X | {0×00000000,0×0000,0×0000,{0×00,0×00,0×00,0×00,0×00,0×00,0×00,0×00} |
I hope this is helpful. Cheers!


