A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Hi @Glenn Maxwell
I tested the script successfully with a sample CSV file and confirmed that the logic is working correctly.
The original issue was mainly due to the script processing a large number of Exchange Online remote cmdlet calls (two calls per mailbox), which can take significant time for thousands of users and may appear to hang without visible progress output.
I also encountered a PowerShell parsing issue related to the pipeline/export section, which was resolved by slightly restructuring the script to store results in an array before exporting.
Additionally, the warning message WARNING: Events from Email parameters of this cmdlet are deprecated. Use Get-EventsFromEmailConfiguration instead. appears to be generated by the Exchange Online module itself and does not affect the script execution.
For bulk-processing scenarios, I also tested the script successfully in PowerShell 7 using ForEach-Object -Parallel with a controlled throttle limit.
I encountered an issue where the UPN column became blank during parallel execution, which was resolved by assigning the UPN value to a local variable inside the parallel block before running the Exchange cmdlets.
The below version worked successfully during testing:
$InputCsv = "C:\Temp\list.csv"
$OutputCsv = "C:\Temp\output.csv"
$users = Import-Csv $InputCsv
$results = $users | ForEach-Object -Parallel {
$UPN = $_.UPN
try {
$regional = Get-MailboxRegionalConfiguration `
-Identity $UPN `
-WarningAction SilentlyContinue `
-ErrorAction Stop
$calendar = Get-MailboxCalendarConfiguration `
-Identity $UPN `
-WarningAction SilentlyContinue `
-ErrorAction Stop
[PSCustomObject]@{
UPN = $UPN
TimeZone = $regional.TimeZone
WorkingHoursTimeZone = $calendar.WorkingHoursTimeZone
}
}
catch {
[PSCustomObject]@{
UPN = $UPN
TimeZone = "ERROR"
WorkingHoursTimeZone = "ERROR"
}
}
} -ThrottleLimit 5
$results | Export-Csv $OutputCsv -NoTypeInformation -Encoding UTF8
A low throttle limit (for example 5–10) is still recommended to help reduce Exchange Online throttling during large-scale processing.
I hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.