From d5ab85739d67fb444080c21c3c5e76ffd7417fc2 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Tue, 14 Oct 2025 18:44:09 +0200 Subject: [PATCH] Clean Up --- shifts_copy.ps1 | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/shifts_copy.ps1 b/shifts_copy.ps1 index 56e7934..3e81b4a 100644 --- a/shifts_copy.ps1 +++ b/shifts_copy.ps1 @@ -192,9 +192,6 @@ try { continue } - #Inicializace dne - $ds_shift_inplace = $false - #Množina emailů pro tento den v týdnu co mají mít home office $ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho' @@ -229,7 +226,7 @@ try { foreach ($email in $allemails) { $userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id - if ($userId -in $shifts_today.UserId){ + if ($userId -in $shifts_today.UserId) { Write-Debug ("{0} has Manual Shift" -f $email) continue; } @@ -273,17 +270,17 @@ try { } } - $params = @{ - notifyTeam = $false - startDateTime = [System.DateTime]::Parse($startSpanDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ")) - endDateTime = [System.DateTime]::Parse($endSpanDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ")) - } - - Invoke-MgShareTeamSchedule -TeamId $team.Id -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin } - ("SHARING: {0}" -f $scheduleGroupName) | Add-Content -Path $logPath - + $params = @{ + notifyTeam = $false + startDateTime = [System.DateTime]::Parse($startSpanDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ")) + endDateTime = [System.DateTime]::Parse($endSpanDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ")) } - catch { - $_ - break; - } \ No newline at end of file + + Invoke-MgShareTeamSchedule -TeamId $team.Id -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin } + ("SHARING: {0}" -f $scheduleGroupName) | Add-Content -Path $logPath + +} +catch { + $_ + break; +} \ No newline at end of file