Last active
February 16, 2021 07:45
-
-
Save danieljoos/22b3319dfe60cb4348d747aebd674d35 to your computer and use it in GitHub Desktop.
TeamViewer - Add large number of SSO exclusion entries from CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install-Module TeamViewerPS | |
Connect-TeamViewerApi | |
# ---- | |
function Split-Bulk { | |
param([int]$Size) | |
Begin { $bulk = New-Object System.Collections.ArrayList($Size) } | |
Process { $bulk.Add($_) | Out-Null; if ($bulk.Count -ge $Size) { ,$bulk.Clone(); $bulk.Clear() } } | |
End { if ($bulk.Count -gt 0) { ,$bulk } } | |
} | |
# ---- | |
$domain = Get-TeamViewerSsoDomain | Where-Object { $_.Name -eq 'example.com' } | |
# ---- | |
Import-Csv ./example.csv | ` | |
Split-Bulk -Size 100 | ` | |
ForEach-Object { ` | |
"Adding bulk of size $($_.Count)" | |
Add-TeamViewerSsoExclusion -DomainId $domain -Email $_.Email | |
} | |
# ---- | |
Get-TeamViewerSsoExclusion -Domain $domain | Measure-Object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment