$fqdn = "" # example "demo.loginvsi.com" $token = "" # example "1It8mrR0us6tpI9SjTO0mdB_EBL0EuO_RkCU69GOGZs" # WARNING: This is needed to ignoring SSL/TLS certificate errors but is a security risk #------------------------------------------------------------------------------------------------------- $code = @" public class SSLHandler {public static System.Net.Security.RemoteCertificateValidationCallback GetSSLHandler() {return new System.Net.Security.RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return true; });} } "@ Add-Type -TypeDefinition $code [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler() #------------------------------------------------------------------------------------------------------- function CreateAccounts-FromCSV { Param ( [Parameter(Mandatory = $true)][string]$username, [Parameter(Mandatory = $true)][string]$domainId, [Parameter(Mandatory = $true)][string]$password ) # WARNING: ignoring SSL/TLS certificate errors is a security risk [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [SSLHandler]::GetSSLHandler() $Body = @{ username = $username domainId = $domainId password = $password } | ConvertTo-Json $Header = @{ "Accept" = "application/json" "Authorization" = "Bearer $token" } $Parameters = @{ Uri = 'https://' + $fqdn + '/publicApi/v6/accounts' # might have to use '/publicApi/v5/accounts' depending on LE version Headers = $header Method = 'POST' Body = $Body ContentType = 'application/json' } $Response = Invoke-RestMethod @Parameters $Response } $csvAccountRows = import-csv "" # put .csv path to import here foreach ($csvAccountRow in $csvAccountRows){ CreateAccounts-FromCSV -username $csvAccountRow.accountNameColumn -domainId $csvAccountRow.domainColumn $csvAccountRow.passwordColumn }