Skip to content

Instantly share code, notes, and snippets.

@rnwood
Created December 8, 2024 19:41
Show Gist options
  • Select an option

  • Save rnwood/e026eef37528f70596957aa30b48ed6e to your computer and use it in GitHub Desktop.

Select an option

Save rnwood/e026eef37528f70596957aa30b48ed6e to your computer and use it in GitHub Desktop.
param (
[int]$RecordCount = 10
)
$firstNames = @("Oliver", "George", "Harry", "Jack", "Jacob", "Noah", "Charlie", "Muhammad", "Thomas", "Oscar")
$lastNames = @("Smith", "Jones", "Taylor", "Brown", "Williams", "Wilson", "Johnson", "Davies", "Robinson", "Wright")
$domains = @("gmail.com", "yahoo.com", "hotmail.com", "outlook.com")
$random = New-Object System.Random
(for ($i = 1; $i -le $RecordCount; $i++) {
$firstName = $firstNames[$random.Next($firstNames.Count)]
$lastName = $lastNames[$random.Next($lastNames.Count)]
$domain = $domains[$random.Next($domains.Count)]
$email = "$firstName.$lastName@$domain".ToLower()
$phoneNumber = "07" + $random.Next(100000000, 999999999)
$record = [PSCustomObject]@{
ID = $i
FirstName = $firstName
LastName = $lastName
Email = $email
PhoneNumber = $phoneNumber
}
Write-Output $record
}) | ConvertTo-Json `
| Out-File -Encoding UTF8 contact.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment