Compare commits
4 Commits
8045198d05
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 87c66c6485 | |||
| ee32d8600b | |||
| bfaa8e50c7 | |||
| 4ddbdc4f2a |
0
logs/.gitkeep
Normal file
0
logs/.gitkeep
Normal file
22
shifts.ps1
22
shifts.ps1
@@ -18,7 +18,7 @@ $ClientId = "6cb76bbf-f253-4551-87a8-5e1f49d8ace3"
|
|||||||
$ClientSecret = "IQg8Q~JTBTDbrHyjKMc.KMSETtQoKWvUhnCr1aY1"
|
$ClientSecret = "IQg8Q~JTBTDbrHyjKMc.KMSETtQoKWvUhnCr1aY1"
|
||||||
$tenantid = "e81b4a31-e8ad-4df6-aa30-3bdcc1da2cdd"
|
$tenantid = "e81b4a31-e8ad-4df6-aa30-3bdcc1da2cdd"
|
||||||
$userIdAdmin = "747bd624-5cd7-4ae0-952f-5dc374e07a5e"
|
$userIdAdmin = "747bd624-5cd7-4ae0-952f-5dc374e07a5e"
|
||||||
$logPath = (".\log_{0}.log" -f (Get-Date).toString("yyyy_MM_dd"))
|
$logPath = (".\logs\log_{0}.log" -f (Get-Date).toString("yyyy_MM_dd"))
|
||||||
|
|
||||||
function Write-Debug {
|
function Write-Debug {
|
||||||
param(
|
param(
|
||||||
@@ -153,6 +153,10 @@ $response = Invoke-RestMethod $authUri -Method 'POST' -Body $body
|
|||||||
|
|
||||||
$token = $response.access_token
|
$token = $response.access_token
|
||||||
|
|
||||||
|
$headers_holiday = @{}
|
||||||
|
|
||||||
|
$headers_holiday.Add("Accept", "application/json")
|
||||||
|
|
||||||
Import-Module Microsoft.Graph.Teams
|
Import-Module Microsoft.Graph.Teams
|
||||||
Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null
|
Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null
|
||||||
|
|
||||||
@@ -178,7 +182,7 @@ $allemails = $schedule.PSObject.Properties | ForEach-Object {
|
|||||||
$today = (Get-Date).Date
|
$today = (Get-Date).Date
|
||||||
|
|
||||||
# ---| Specific date |---
|
# ---| Specific date |---
|
||||||
#$today = Get-Date -Day 27 -Month 10 -Year 2025 -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
#$today = Get-Date -Day 20 -Month 10 -Year 2025 -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
||||||
|
|
||||||
$daysahead = 14 #How many days ahead to plan
|
$daysahead = 14 #How many days ahead to plan
|
||||||
$timeoff_past_look = -7 #How many days to look into the past for the start of a multi-day time off
|
$timeoff_past_look = -7 #How many days to look into the past for the start of a multi-day time off
|
||||||
@@ -211,7 +215,7 @@ try {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$timeSpan = New-TimeSpan -Start $startSpanDate -End $endSpanDate
|
$timeSpan = New-TimeSpan -Start $startSpanDate -End $endSpanDate
|
||||||
Write-Debug("Planning from {0} to {1}" -f $startSpanDate, $endSpanDate)
|
Write-Debug("Planning from {0} to {1}" -f $startSpanDate, $endSpanDate)
|
||||||
|
|
||||||
@@ -225,6 +229,14 @@ try {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---| HOLIDAY CHECK |---
|
||||||
|
$holiday_response = (Invoke-WebRequest -Uri "https://svatky.steelants.cz/api/$($dayDate.ToString('yyyy-MM-dd'))" -Method GET -Headers $headers_holiday) | ConvertFrom-Json
|
||||||
|
|
||||||
|
if($holiday_response.isPublicHoliday) {
|
||||||
|
Write-Debug("{0} {1}: skipping holiday" -f $dayDate, $dayDate.DayOfWeek)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
# ---| NEW DAY INIT |---
|
# ---| NEW DAY INIT |---
|
||||||
$ds_shift_inplace = $false
|
$ds_shift_inplace = $false
|
||||||
$ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'
|
$ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'
|
||||||
@@ -337,7 +349,7 @@ try {
|
|||||||
else {
|
else {
|
||||||
# ---| LOOKING FOR THE SHIFT |---
|
# ---| LOOKING FOR THE SHIFT |---
|
||||||
foreach ($shift in $shifts_today) {
|
foreach ($shift in $shifts_today) {
|
||||||
if($shift.UserId -eq $futureds_id) {
|
if($shift.UserId -eq $futureds_id -and $shift.SharedShift.Notes -ne "On-site") {
|
||||||
# ---| REMOVE THE SHIFT |---
|
# ---| REMOVE THE SHIFT |---
|
||||||
Remove-Shift -shift $shift -teamID $team.Id
|
Remove-Shift -shift $shift -teamID $team.Id
|
||||||
|
|
||||||
@@ -380,7 +392,7 @@ try {
|
|||||||
# ---| ON-SITE SHIFT CHECK |---
|
# ---| ON-SITE SHIFT CHECK |---
|
||||||
if($email -in $os_emails) {
|
if($email -in $os_emails) {
|
||||||
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
if((Invoke-HasShiftorTimeOff -UID $userId -shifts $shifts_today -timeoff $timeoff_today -mail $email) -eq $false) {
|
||||||
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "On-site" -StartDate $dateStart -EndDate $dateEnd -color "gray" -teamID $team.id -mail $email
|
$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "On-site" -StartDate $dateStart -EndDate $dateEnd -color "white" -teamID $team.id -mail $email
|
||||||
$allshifts += [Object[]] $newshift
|
$allshifts += [Object[]] $newshift
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
310
shifts_copy.ps1
310
shifts_copy.ps1
@@ -1,310 +0,0 @@
|
|||||||
param(
|
|
||||||
[switch]$debug,
|
|
||||||
[switch]$clear
|
|
||||||
)
|
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
$script:debug = $debug
|
|
||||||
}
|
|
||||||
|
|
||||||
$teamsName = "IT Support & Delivery"
|
|
||||||
$scheduleGroupName = "IT SUPPORT"
|
|
||||||
|
|
||||||
# App Registration details & Tenant ID
|
|
||||||
$ClientId = "6cb76bbf-f253-4551-87a8-5e1f49d8ace3"
|
|
||||||
$ClientSecret = "IQg8Q~JTBTDbrHyjKMc.KMSETtQoKWvUhnCr1aY1"
|
|
||||||
$tenantid = "e81b4a31-e8ad-4df6-aa30-3bdcc1da2cdd"
|
|
||||||
$userIdAdmin = "747bd624-5cd7-4ae0-952f-5dc374e07a5e"
|
|
||||||
$logPath = (".\log_{0}.log" -f (Get-Date).toString("yyyy_MM_dd"))
|
|
||||||
|
|
||||||
function Write-Debug {
|
|
||||||
param(
|
|
||||||
[string]$message
|
|
||||||
)
|
|
||||||
if ($script:debug) {
|
|
||||||
Write-Host $message
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$message | Add-Content $logPath
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Naplánování konkrétní směny
|
|
||||||
function Set-Shift {
|
|
||||||
param(
|
|
||||||
[string]$userId,
|
|
||||||
[string]$groupID,
|
|
||||||
[string]$shiftName,
|
|
||||||
[System.DateTime]$StartDate,
|
|
||||||
[System.DateTime]$EndDate,
|
|
||||||
[string]$color,
|
|
||||||
[string]$teamID,
|
|
||||||
[string]$mail
|
|
||||||
)
|
|
||||||
|
|
||||||
$params = @{
|
|
||||||
UserId = $userId
|
|
||||||
schedulingGroupId = $groupID
|
|
||||||
sharedShift = @{
|
|
||||||
notes = ($shiftName)
|
|
||||||
startDateTime = [System.DateTime]::Parse($StartDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ"))
|
|
||||||
endDateTime = [System.DateTime]::Parse($EndDate.ToString("yyyy-MM-dd'T'HH:mm:ssZ"))
|
|
||||||
theme = $color
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#$headers = @{
|
|
||||||
# "MS-APP-ACTS-AS" = $userIdAdmin
|
|
||||||
# "Prefer" = "no-notification"
|
|
||||||
#}
|
|
||||||
|
|
||||||
$newShift = New-MgTeamScheduleShift -TeamId $teamID -BodyParameter $params -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin }
|
|
||||||
#Write-Debug ("SCHEDULING: {0} {1} - {2}" -f $newShift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm"), $newShift.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm"), $newShift.SharedShift.Notes)
|
|
||||||
#("SCHEDULING: {0} {1} - {2}" -f $newShift.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm"), $newShift.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm"), $newShift.SharedShift.Notes) | Add-Content -Path $logPath
|
|
||||||
Write-Debug ("{0} {1}: {2} {3} {4} {5}" -f $dayDate, $dayDate.DayOfWeek, $mail, $shiftName, $StartDate, $EndDate)
|
|
||||||
#$newShift = 0
|
|
||||||
return $newShift
|
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-HasTimeOff {
|
|
||||||
param(
|
|
||||||
[string]$UID,
|
|
||||||
[PSCustomObject]$timeoff,
|
|
||||||
[string]$mail
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($toff in $timeoff) {
|
|
||||||
if ($toff.UserId -eq $UID) {
|
|
||||||
Write-Debug ("{0} {1}: {2} has time off at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
|
||||||
return $true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $false
|
|
||||||
}
|
|
||||||
function Invoke-HasShift {
|
|
||||||
param(
|
|
||||||
[string]$UID,
|
|
||||||
[PSCustomObject]$shifts,
|
|
||||||
[string]$mail
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($shift in $shifts) {
|
|
||||||
if ($shift.UserId -eq $UID) {
|
|
||||||
Write-Debug ("{0} {1}: {2} has a shift at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
|
||||||
return $true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $false
|
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-HasShiftorTimeOff {
|
|
||||||
param(
|
|
||||||
[string]$UID,
|
|
||||||
[PSCustomObject]$shifts,
|
|
||||||
[PSCustomObject]$timeoff,
|
|
||||||
[string]$mail
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($shift in $shifts) {
|
|
||||||
if ($shift.UserId -eq $UID) {
|
|
||||||
Write-Debug ("{0} {1}: {2} has a shift or time off at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
|
||||||
return $true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($toff in $timeoff) {
|
|
||||||
if ($toff.UserId -eq $UID) {
|
|
||||||
Write-Debug ("{0} {1}: {2} has a shift or time off at this time" -f $dayDate, $dayDate.DayOfWeek, $mail)
|
|
||||||
return $true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $false
|
|
||||||
}
|
|
||||||
|
|
||||||
#Microsoft auth
|
|
||||||
$body = @{
|
|
||||||
grant_type = "client_credentials"
|
|
||||||
resource = "https://graph.microsoft.com"
|
|
||||||
client_id = $ClientId
|
|
||||||
client_secret = $ClientSecret
|
|
||||||
}
|
|
||||||
$authUri = "https://login.microsoftonline.com/$tenantid/oauth2/token"
|
|
||||||
$response = Invoke-RestMethod $authUri -Method 'POST' -Body $body
|
|
||||||
|
|
||||||
$token = $response.access_token
|
|
||||||
|
|
||||||
Import-Module Microsoft.Graph.Teams
|
|
||||||
Connect-MgGraph -AccessToken $($token | ConvertTo-SecureString -AsPlainText -Force) >> $null
|
|
||||||
|
|
||||||
# Dnešní datum a plán směn
|
|
||||||
|
|
||||||
#$today = (Get-Date).Date
|
|
||||||
#$today = $today_old.AddYears(2)
|
|
||||||
$today = (Get-Date -Day 14 -Month 10 -Year 2025).Date
|
|
||||||
|
|
||||||
$schedule = Get-Content -Path "./config.json" -Raw | ConvertFrom-Json
|
|
||||||
|
|
||||||
$allemails = $schedule.PSObject.Properties | ForEach-Object {
|
|
||||||
if ($_.Name -in @("monday", "tuesday", "wednesday", "thursday", "friday")) {
|
|
||||||
$_.Value.PSObject.Properties | ForEach-Object {
|
|
||||||
if ($_.Name -in @("ds", "ho", "os", "ns")) {
|
|
||||||
$_.Value | ForEach-Object {
|
|
||||||
$_
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} | Select-Object -Unique
|
|
||||||
|
|
||||||
#Časové rozmezí plánování
|
|
||||||
|
|
||||||
$daysahead = 5
|
|
||||||
|
|
||||||
$startSpanDate = Get-Date -Day $today.Day -Month $today.Month -Year $today.Year -Hour 9 -Minute 00 -Second 00 -Millisecond 00
|
|
||||||
$endSpanDate = Get-Date -Day $startSpanDate.AddDays($daysahead).Day -Month $startSpanDate.AddDays($daysahead).Month -Year $startSpanDate.AddDays($daysahead).Year -Hour 17 -Minute 00 -Second 00 -Millisecond 00
|
|
||||||
|
|
||||||
#RLCZ maintenance
|
|
||||||
$rlcz_mtnc_email = "jiri.kotlan@itego.cz"
|
|
||||||
$rlcz_shift_reduction = -3
|
|
||||||
|
|
||||||
# SKRIPT
|
|
||||||
try {
|
|
||||||
$team = Get-MgTeam -Property "id,displayName" | Where-Object -property displayName -value $teamsName -eq
|
|
||||||
$group = Get-MgTeamScheduleSchedulingGroup -TeamId $team.id -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin } | Where-Object -property displayName -value $scheduleGroupName -eq
|
|
||||||
|
|
||||||
$allshifts = [object[]] (Get-MgTeamScheduleShift -TeamId $team.id -Filter "SharedShift/StartDateTime ge $($startSpanDate.toString('yyyy-MM-ddT00:00:00Z'))" -All -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin })
|
|
||||||
$timeoff_all = [object[]] (Get-MgTeamScheduleTimeOff -TeamId $team.id -Filter "SharedTimeOff/StartDateTime ge $($startSpanDate.toString('yyyy-MM-ddT00:00:00Z'))" -All -Headers @{ "MS-APP-ACTS-AS" = $userIdAdmin } | Select-Object -Property *, @{name = "Date"; expression = { $_.SharedTimeOff.StartDateTime.AddHours(1).Date } })
|
|
||||||
|
|
||||||
#Procházíme dny v časovém rozmezí
|
|
||||||
$timeSpan = New-TimeSpan -Start $startSpanDate -End $endSpanDate
|
|
||||||
Write-Debug ("Planning from {0} to {1}" -f $startSpanDate, $endSpanDate)
|
|
||||||
|
|
||||||
for ($dayNumber = 0; $dayNumber -lt $timespan.Days; $dayNumber++) {
|
|
||||||
$dayDate = $today.AddDays($dayNumber);
|
|
||||||
|
|
||||||
#Pokud jde o pracovní den, jinak se jde ihned na další den
|
|
||||||
if ($dayDate.DayOfWeek -in @("Saturday", "Sunday")) {
|
|
||||||
Write-Debug ("is weekend {0}" -f $dayDate)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
#Množina emailů pro tento den v týdnu co mají mít home office
|
|
||||||
$ho_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ho'
|
|
||||||
|
|
||||||
#Email a ID toho kdo má mít tento den denní směnu
|
|
||||||
$ds_email = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ds'
|
|
||||||
|
|
||||||
#Emaily těch co jsou on-site u zákazníka
|
|
||||||
$os_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'os'
|
|
||||||
|
|
||||||
#Emaily těch co nemají mít dnes žádnou směnu
|
|
||||||
$ns_emails = $schedule.($dayDate.DayOfWeek.ToString().ToLower()).'ns'
|
|
||||||
|
|
||||||
#Upravení času
|
|
||||||
$dateStart = $(get-date -Day $dayDate.Day -Month $dayDate.Month -Year $dayDate.Year -Hour 9 -Minute 00 -Second 00).AddHours(-1)
|
|
||||||
$dateEnd = $(get-date -Day $dayDate.Day -Month $dayDate.Month -Year $dayDate.Year -Hour 17 -Minute 00 -Second 00).AddHours(-1)
|
|
||||||
|
|
||||||
if (($dayDate.IsDaylightSavingTime()) -eq $true) {
|
|
||||||
$dateStart = $dateStart.AddHours(-1)
|
|
||||||
$dateEnd = $dateEnd.AddHours(-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
$shifts_today = [Object[]] $allshifts | Where-Object -Filter {
|
|
||||||
$_.schedulingGroupId -eq $group.Id -and $_.SharedShift.StartDateTime.ToString("yyyy-MM-dd HH:mm") -ge $dateStart.ToString("yyyy-MM-dd HH:mm") -and $_.SharedShift.EndDateTime.ToString("yyyy-MM-dd HH:mm") -le $dateEnd.ToString("yyyy-MM-dd HH:mm")
|
|
||||||
}
|
|
||||||
|
|
||||||
$timeoff_today = [Object[]] $timeoff_all | Where-Object -Filter {
|
|
||||||
($_.SharedTimeOff.StartDateTime.Date -eq $dateStart.Date -or $_.SharedTimeOff.EndDateTime.Date -eq $dateEnd.Date)
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Debug ("Shifts {0}, TimeOff: {1}" -f $shifts_today.length, $timeoff_today.length)
|
|
||||||
$ds_covered = $false;
|
|
||||||
|
|
||||||
$userEmailToIdHashtable = @{}
|
|
||||||
$userEmailNotAvailable = @()
|
|
||||||
|
|
||||||
foreach ($email in $allemails) {
|
|
||||||
$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) {
|
|
||||||
$userEmailNotAvailable += $email
|
|
||||||
Write-Debug ("{0} has Manual Shift" -f $email)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($userId -in $timeoff_today.UserId) {
|
|
||||||
$userEmailNotAvailable += $email
|
|
||||||
Write-Debug ("{0} has TimeOff" -f $email)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#NoShift
|
|
||||||
if ($email -in $ns_emails) {
|
|
||||||
$userEmailNotAvailable += $email
|
|
||||||
Write-Debug ("{0} has NULL Shift " -f $email)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
#OnSite
|
|
||||||
if ($email -in $os_emails) {
|
|
||||||
Write-Debug ("{0} has On Site " -f $email)
|
|
||||||
#$newshift = Set-Shift -userId $userId -groupID $group.id -shiftName "On-site" -StartDate $dateStart -EndDate $dateEnd -color "gray" -teamID $team.id -mail $os_email
|
|
||||||
#$allshifts += [Object[]] $newshift
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
#Dení Směna
|
|
||||||
if ($email -eq $ds_email -and $email -in $ho_emails) {
|
|
||||||
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
|
|
||||||
#$allshifts += [Object[]] $newshift
|
|
||||||
$ds_covered = $true;
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
elseif ($email -eq $ds_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
|
|
||||||
#$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
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Debug ("{0} has Office" -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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$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
|
|
||||||
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$_
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user