Samples/CreateEndpoints.ps1

# With this script you can create $amount windowsendpoints in a specific logical group default pagesize (Get and Post example)

$logicalGroupName = "YourLogicalGroup"
$displayNameEP = "YourEndpointDisplayName"
$hostNameEP = "YourEndpointHostName"
$amount = 30

try {
    # Try to get the logical group
    $logicalGroup = Get-bCEndpointsLogicalGroups -Name $logicalGroupName

    # If not found, then create a logical group with this name
    if ($logicalGroup.totalItems -eq 0) {
        # Creating the logical gruop blueprint
        $newLogicalGroup = Initialize-bCEndpointsLogicalGroupForCreation -Name $logicalGroupName

        # Creating the logical group
        $newLogicalGroup = New-bCEndpointsLogicalGroup -LogicalGroupForCreation $newLogicalGroup

        # Get the created logical group
        Write-Output "Created new Logical group with name" $newLogicalGroup.name

        # Retrieve the logical group id
        $logicalGroupId = $newLogicalGroup.id
    } else{
        # Retrieve the logical group id
        $logicalGroupId = $logicalGroup.data[0].id
    }

    for($i = 1; $i -le $amount; $i++){

        # Set the displayname and hostname
        $displayName = ($displayNameEP + $i)
        $hostName = ($hostNameEP + $i)

        # Creating the endpoint blueprint
        $newEndpoint = Initialize-bCEndpointsWindowsEndpointForCreation -DisplayName $displayName -HostName $hostName -LogicalGroupId $logicalGroupId -Domain "yourDomain"

        # Creating the endpoint
        New-bCEndpointsWindowsEndpoint -WindowsEndpointForCreation $newEndpoint
        Write-Output "Created new Windows Endpoint with name" $displayName
    }
}
catch {
    Write-Error "Error occured: $($_.Exception)"
}