Aska_Teams_WorkingTimeZone_01

微軟 Teams 是目前很多企業在使用的通訊軟體,其中一個貼心的小功能,讓我覺得很棒的,就是 Teams 可以很快得知同事的工作時間 (痛哭流涕),尤其他是你的國外同事而且跟你不同時區,請大家多多關心工程師及他的家人好嗎?

不過,前陣子收到同事反應說有人的工作時區顯示不正確,我很快地查了一下幾個在台灣辦公室常往來的同事,確認有幾個顯示不正常,查起來都是 UTC -8 時區 (還是他們領國外薪水!?)。

感謝同事跟微軟技術支援聯繫,透過微軟工程師協助,用下面指令可以查到使用者的工作時區設定,我們發現異常的,其值都是「tzone://Microsoft/Custom」

Get-MailboxCalendarConfiguration -Identity User_Principal_Name

Aska_Teams_WorkingTimeZone_02

要修正很簡單,參考下面的指令,就能完成修復。

Set-MailboxCalendarConfiguration -Identity UPN -WorkingHoursTimeZone "時區名稱"

Aska_Teams_WorkingTimeZone_03

延伸問題來了,如果不是台北標準時間的同事,他們的時區名稱要填什麼,畢竟也要關心一下國外同事的身心健康,我們可以用 PS 指令在 Windows 環境查到完整對應資料如下。

 $TimeZone = Get-ChildItem "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Time zones" | foreach {Get-ItemProperty $_.PSPath}; $TimeZone | sort Display | Format-Table -Auto PSChildname,Display

Aska_Teams_WorkingTimeZone_name

好的,接下來可能會再問的是,到底公司有多少工作時區顯示不正常的使用者?
我參考過去寫過的 PS 報表,調整了一下內容,有興趣的可以用他產生清單看看。

#Connect to AzureAD
Write-Host 'Connecting to AzureAD' -ForegroundColor Yellow
#Connect-AzureAD

#ExportFile
$AADName = @((@((Get-AzureADDomain | Where-Object {$_.Name -like "*.onmicrosoft.com"}).Name )[0]).Split("."))[0]
$ExportFilePath = "C:\Temp\" + $AADName + "_Uers_WorkingHoursTime_" + "$((Get-Date -format yyyy-MMdd).ToString()).csv"

Write-Host 'Obtaining WorkingHoursTime for your users in domain' -ForegroundColor Yellow
$EXOMailbox = Get-EXOMailbox -ResultSize Unlimited | Sort-Object DisplayName
$Users = foreach ($a in $EXOMailbox)
 {
     try
     {
         $p = Get-MailboxCalendarConfiguration -Identity $a.UserPrincipalName
         [pscustomobject]@{DisplayName=$a.DisplayName; PrimarySmtpAddress=$a.PrimarySmtpAddress ;WorkingHoursStartTime=$p.WorkingHoursStartTime; WorkingHoursEndTime=$p.WorkingHoursEndTime; WorkingHoursTimeZone=$p.WorkingHoursTimeZone}
     }
     catch
     {
         continue
     }
}

#$Users | Out-Host
#Export list for checking
$Users | Export-Csv -NoTypeInformation -Encoding UTF8 -Path $ExportFilePath

產生結果可參考如下圖,而且可以很快利用 VSCode 加上外掛做資料篩選。
Aska_Teams_WorkingTimeZone_list

清單產生指令執行過程,如出現「WARNING: Events from Email parameters of this cmdlet are deprecated. Use Get-EventsFromEmailConfiguration instead.」此屬正常現象,勿驚慌勿害怕。至於,為什麼有使用者的工作時區的值是「tzone://Microsoft/Custom」,這就不可考了。對我來說,現階段先把問題修復比較重要。

參考資料
MS Doc - Set-MailboxCalendarConfiguration
Office 365 for IT Pros - How Microsoft Teams Displays Local Time in User Profile Cards