Fixes
This commit is contained in:
@@ -222,22 +222,30 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Debug ("Shifts {0}, TimeOff: {1}" -f $shifts_today.length, $timeoff_today.length)
|
Write-Debug ("Shifts {0}, TimeOff: {1}" -f $shifts_today.length, $timeoff_today.length)
|
||||||
|
$ds_covered = $false;
|
||||||
|
|
||||||
|
$userEmailToIdHashtable = @{}
|
||||||
|
$userEmailNotAvailable = @()
|
||||||
|
|
||||||
foreach ($email in $allemails) {
|
foreach ($email in $allemails) {
|
||||||
$userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id
|
$userId = $(Get-MgUser -Filter "UserPrincipalName eq '$email' or proxyAddresses/any(c:c eq 'smtp:$email')").Id
|
||||||
|
$userEmailToIdHashtable[$email] = $userId
|
||||||
|
|
||||||
if ($userId -in $shifts_today.UserId) {
|
if ($userId -in $shifts_today.UserId) {
|
||||||
|
$userEmailNotAvailable += $email
|
||||||
Write-Debug ("{0} has Manual Shift" -f $email)
|
Write-Debug ("{0} has Manual Shift" -f $email)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($userId -in $timeoff_today.UserId) {
|
if ($userId -in $timeoff_today.UserId) {
|
||||||
|
$userEmailNotAvailable += $email
|
||||||
Write-Debug ("{0} has TimeOff" -f $email)
|
Write-Debug ("{0} has TimeOff" -f $email)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#NoShift
|
#NoShift
|
||||||
if ($email -in $ns_emails) {
|
if ($email -in $ns_emails) {
|
||||||
|
$userEmailNotAvailable += $email
|
||||||
Write-Debug ("{0} has NULL Shift " -f $email)
|
Write-Debug ("{0} has NULL Shift " -f $email)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -255,12 +263,28 @@ try {
|
|||||||
Write-Debug ("{0} has Denní HO" -f $email)
|
Write-Debug ("{0} has Denní HO" -f $email)
|
||||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Home Office - Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||||
#$allshifts += [Object[]] $newshift
|
#$allshifts += [Object[]] $newshift
|
||||||
|
$ds_covered = $true;
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
elseif ($email -eq $ds_email) {
|
elseif ($email -eq $ds_email) {
|
||||||
Write-Debug ("{0} has Denní" -f $email)
|
Write-Debug ("{0} has Denní" -f $email)
|
||||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Denní směna" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||||
#$allshifts += [Object[]] $newshift
|
#$allshifts += [Object[]] $newshift
|
||||||
|
$ds_covered = $true;
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
||||||
|
($_.SharedTimeOff.StartDateTime.Date -eq $dateStart.Date -or $_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($email in ($allemails | Where-Object -Filter {$_ -notin $userEmailNotAvailable} | Where-Object -Filter {$userEmailToIdHashtable[$_] -notin $timeoff_today.UserId})) {
|
||||||
|
if (($ds_covered -eq $false)) {
|
||||||
|
$ds_covered = $true;
|
||||||
|
Write-Debug ("{0} has backup Denní" -f $email)
|
||||||
|
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "Office" -StartDate $dateStart -EndDate $dateEnd -color "purple" -teamID $team.id -mail $ds_email
|
||||||
|
#$allshifts += [Object[]] $newshift
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user