Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremy-jameson/8a0d0e618dcc21cf1a174b7b7925d6fb to your computer and use it in GitHub Desktop.
Save jeremy-jameson/8a0d0e618dcc21cf1a174b7b7925d6fb to your computer and use it in GitHub Desktop.
Bulk Create Test E-mail Accounts in Poste.io Using PowerShell

Bulk Create Test E-mail Accounts in Poste.io

$uri = "https://mail-test.technologytoolbox.com/admin/api/v1/boxes"

$userPassword = "{specify test mail password here}"

$adminUsername = "admin@technologytoolbox.com"
$adminPassword = "{specify Poste.io admin password here}"
$credentials = "${adminUsername}:${adminPassword}"

$bytes = [System.Text.Encoding]::ASCII.GetBytes($credentials)
$encodedCredentials = [System.Convert]::ToBase64String($bytes)

$headers = @{ Authorization = "Basic $encodedCredentials" }

Get-ADUser -Filter { EmailAddress -like "*@*" } -Properties Name, EmailAddress |
    foreach { 
        $body = @{
            name = $_.Name
            email = $_.EmailAddress
            passwordPlaintext = $userPassword
        }

        Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $body
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment