Tuesday, May 21, 2013

How to generate many GUIDs using PowerShell


Use this simple PowerShell script:

$i = 1
do {
    $guidObject = [System.Guid]::NewGuid()
    Write-Output $guidObject.Guid >>c:\1.csv
    $i++ }
while ($i -le 1000)


Save the code above to a file with .ps1 extension, right click on it -> Run with PowerShell. 1000 random the GUIDs will be written to a file named C:\1.csv

To run PowerShell scripts, you need to configure PowerShell to allow them. Run in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

When prompted, type Y and press enter.

No comments :

Post a Comment