Samples/PagingHelper.ps1
# With this Script you can get endpoints with the build-in paging helper method Select-bCPageData # This script serves as an piping example # Sets Write-Information for console output # PowerShell default is SilentlyContinue $InformationPreference = "Continue" $logicalGroupName = "yourLogicalGroup" $displayNameEP = "yourEndpointName" $operationPath = "/logicalGroupId" try { # Get all possible endpoints with the displayname $displayNameEP in an object which consists of pages $allPossiblePages = Get-bCEndpointsWindowsEndpoints -GetAllPages -SearchQuery $displayNameEP -PageSize 10 $allPossiblePages # Get all possible endpoints with the displayname $displayNameEP in an object which consists of page data # Paging example with the given helper method Select-bCPageData $allEndpointData = Get-bCEndpointsWindowsEndpoints -GetAllPages -SearchQuery $displayNameEP | Select-bCPageData $allEndpointData # Piping example: get specific endpoints and change its properties # Get windows endpoints with the name $displayNameEP and check if they are assigned to the standard logical group $endpointsInNoLogicalGroup = Get-bCEndpointsWindowsEndpoints -GetAllPages -SearchQuery $displayNameEP -PageSize 10 ` | Select-bCPageData ` | Where-Object { Write-Information "Processing Endpoint $($_.displayName)" return $_.logicalGroup -eq "Logical group" } # Get the logical group object with the paging helper Select-bCPageData $customLogicalGroup = Get-bCEndpointsLogicalGroups -Name $logicalGroupName | Select-bCPageData # Change the logical group of the collected endpoints to an custom logical group foreach ($endpoint in $endpointsInNoLogicalGroup) { $operation = Initialize-bCPatchOperation -Op replace -Path $operationPath -Value $customLogicalGroup.id $updatedEndpoint = Update-bCEndpointsWindowsEndpoint -Id $endpoint.id -Operation $operation Write-Output "The logical group changed for endpoint $($updatedEndpoint.displayName) to $($updatedEndpoint.logicalGroup)" } } catch { Write-Error "Error occured: $($_.Exception)" } |