Samples/RemoveCreatedEndpoints.ps1
# This script removes/deletes endpoints of a logical group with pagesize of 3 (Get and Delete example) $logicalGroupName = "YourLogicalGroup" $pageSize = 3 try{ # Get the logical group $logicalGroup = Get-bCEndpointsLogicalGroups -Name $logicalGroupName # retrieve the logical group id $logicalGroupID = $logicalGroup.data[0].id Write-Output $logicalGroupID # Get the endpoints out of the logical group $endpointsLogicalGroup = Get-bCEndpointsEndpointsByLogicalGroupId -LogicalGroupId $logicalGroupID -PageSize $pageSize # Array to save the endpoints $endpointsList = @() # For loop iterates through the pages for($i = 1; $i -le $endpointsLogicalGroup.totalPages; $i++){ # Get the endpoints of the current page $endpointsPage = Get-bCEndpointsEndpointsByLogicalGroupId -LogicalGroupId $logicalGroupID -Page $i -PageSize $pageSize # Add the current endpoints of the page to the array foreach($endpointData in $endpointsPage.data){ $endpointsList += $endpointData } } # Deletes the endpoints in the Array foreach ($endpoint in $endpointsList) { # Removes the endpoint by the ID Remove-bCEndpointsEndpoint -Id $endpoint.id # Check if endpoint got deleted if (!{Get-bCEndpointsEndpoint -Id $endpoint.id}.data) { Write-Output "Deleted endpoint $($endpoint.displayName)" } else{ Write-Output "Endpoint: $($endpoint.displayName) wasn't deleted" } } } catch { Write-Error "Error occured: $($_.Exception)" } |