Public/New-TEApiUser.ps1

function New-TEApiUser
{
    [CmdletBinding()]
    Param(
        ##### Common Parameters #####
        [Parameter( Mandatory=$false, 
            Position = 0)]
        [string]$email,

        [Parameter( Mandatory=$false, 
            Position = 1)]
        [int]$loginAG,

        [Parameter( Mandatory=$false, 
            Position = 1)]
        [int]$roleId,

        [Parameter( Mandatory=$false)]
        [hashtable]$userList
    )

    Begin{}

    Process{
        # Create a Body array and add email and login account group to body
        $body = @{}
        $loginAccountGroup = @{}
        $allAccountGroupRoles = @{}

            foreach ($user in $email) {
                

                $loginAccountGroup.aid          = $loginAG
                $allAccountGroupRoles.roleId    = $roleId
                $body.email                     = $email
                $body.loginAccountGroup         = $loginAccountGroup

                # Convert Body to json
                $jsonBody = $body | ConvertTo-Json 


                $urlComponentsList = New-Object System.Collections.Generic.List[System.Object]
                $urlComponentsList.add('users')
                $urlComponentsList.add('new')
                $urlComponents = $urlComponentsList.ToArray()
          
                Write-Output $jsonbody
                $results = send-TEApi -method post -urlcomponents $urlComponents -body $jsonBody
                #Write-host "Test Created Successfully" -ForegroundColor Green
                Write-Output $results.email
            }
        }
    End{}
}