<commit_before>﻿$tescoUsersGroupId = "3c48c759-8ce8-4eab-9dc3-984305593446"
$tescoDevicesGroupId = "35847d50-69c2-4b76-8737-5942954754c4"

$tescoUsers = get-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -groupId $tescoUsersGroupId -memberType TransitiveMembers -returnOnlyLicensedUsers
$tescoWindowsDevices = get-graphDevices -tokenResponse $teamBotTokenResponse -filterOwnerIds $tescoUsers.id -filterOperatingSystem Windows
$currentTescoDevices = get-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -groupId $tescoDevicesGroupId -memberType TransitiveMembers
if([string]::IsNullOrWhiteSpace($tescoWindowsDevices.Id)){$tescoWindowsDevices = @()}
if([string]::IsNullOrWhiteSpace($currentTescoDevices.Id)){$currentTescoDevices = @()}

$delta = Compare-Object -ReferenceObject $currentTescoDevices -DifferenceObject $tescoWindowsDevices -Property Id -PassThru

$toAdd = $delta | ? {$_.SideIndicator -eq "=>"} 
add-graphUsersToGroup -tokenResponse $teamBotTokenResponse -graphGroupId $tescoDevicesGroupId -memberType Members -graphUserIds $toAdd.id -Verbose

$toRemove = $delta | ? {$_.SideIndicator -eq "<="} 
remove-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -graphGroupId $tescoDevicesGroupId -memberType Members -graphUserIds $toRemove.id -Verbose<commit_msg>If statement to reduce errors<commit_after>﻿$teamBotDetails = get-graphAppClientCredentials -appName TeamsBot
$teamBotTokenResponse = get-graphTokenResponse -aadAppCreds $teamBotDetails

$tescoUsersGroupId = "3c48c759-8ce8-4eab-9dc3-984305593446"
$tescoDevicesGroupId = "35847d50-69c2-4b76-8737-5942954754c4"

$tescoUsers = get-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -groupId $tescoUsersGroupId -memberType TransitiveMembers -returnOnlyLicensedUsers
$tescoWindowsDevices = get-graphDevices -tokenResponse $teamBotTokenResponse -filterOwnerIds $tescoUsers.id -filterOperatingSystem Windows
$currentTescoDevices = get-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -groupId $tescoDevicesGroupId -memberType TransitiveMembers
if([string]::IsNullOrWhiteSpace($tescoWindowsDevices.Id)){$tescoWindowsDevices = @()}
if([string]::IsNullOrWhiteSpace($currentTescoDevices.Id)){$currentTescoDevices = @()}

$delta = Compare-Object -ReferenceObject $currentTescoDevices -DifferenceObject $tescoWindowsDevices -Property Id -PassThru

$toAdd = $delta | ? {$_.SideIndicator -eq "=>"}
If($toAdd){add-graphUsersToGroup -tokenResponse $teamBotTokenResponse -graphGroupId $tescoDevicesGroupId -memberType Members -graphUserIds $toAdd.id -Verbose}

$toRemove = $delta | ? {$_.SideIndicator -eq "<="}
If($toRemove){remove-graphUsersFromGroup -tokenResponse $teamBotTokenResponse -graphGroupId $tescoDevicesGroupId -memberType Members -graphUserIds $toRemove.id -Verbose}
{'fraction_non_alphanumeric': 0.10577617328519856, 'fraction_numerical': 0.0368231046931408, 'mean_word_length': 8.42517006802721, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3920549', 'n_tokens_mistral': 930, 'n_tokens_neox': 887, 'n_words': 147}