Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • 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 = "[email protected]"
$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