OneDrive for Business: Change Time Zone using PowerShell

Requirement: Change time zone for OneDrive for business site.

How to Set OneDrive for Business Timezone?
The default region and timezone for the tenant is set when you selected your organization's region at the time of registering. This cannot be changed once its set. If you noticed, OneDrive site default timezone is set to "(UTC-08:00) Pacific Time (US and Canada)". This leads to inconsistency in date field values such as "Created", "Modified On",etc. and many users started complaining that their time zone settings are incorrect!. you may probably want to change timezone of your OneDrive site. As an owner of your own OneDrive, you can use the instructions below to change the timezone your OneDrive site.
  • Logon to Office 365 and go to your OneDrive site. Typically at: https://your-tenant-my.sharepoint.com/personal/YOUR_LOGIN_ID.
  • In the top- right corner of the screen, Click on the gear icon and choose "OneDrive settings" from the menu.
    onedrive timezone setting
  • From the Site Settings page, Click on "More Settings" in the left navigation >> Click on "Regional Settings" Link
  • On the regional settings page, Time zone settings is located at the top of the page. Use the drop down menu to change the time zone as per your requirements. Click on "OK" button on the bottom to save your changes.
    onedrive for business change time zone

Once you are done, Time stamps on files in your OneDrive will be changed to match the new zone.

Change OneDrive Timezone using PowerShell
While its possible for your users to set the timezone for their own OneDrive sites, As an Administrator you can set timezone for all OneDrive for business Sites using PowerShell.
#Set Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$TimezoneName = "(UTC) Dublin, Edinburgh, Lisbon, London"

#Get Credentials to connect
$Cred  = Get-Credential
 
#Connect to PnP Online to the Tenant Admin Site
Connect-PnPOnline -Url $AdminSiteURL -Credentials $Cred
 
#Get All OneDrive for Business Sites
$OneDriveSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'"

#Loop through each site
ForEach($Site in $OneDriveSites)
{ 
    Write-Host -f Yellow "Processing Site: "$Site.URL

    #Connect to OneDrive for Business Site
    Connect-PnPOnline $Site.URL -Credentials $Cred
 
    #Get the Web
    $web = Get-PnPWeb -Includes RegionalSettings.TimeZones
 
    #Get the time zone
    $Timezone  = $Web.RegionalSettings.TimeZones | Where {$_.Description -eq $TimezoneName}
 
    If($Timezone -ne $Null)
    {
        #Update time zone of the site
        $Web.RegionalSettings.TimeZone = $Timezone
        $Web.Update()
        Invoke-PnPQuery
        Write-host "`tTimezone Updated Successfully!" -ForegroundColor Green
    }
    else
    {
        Write-host "Timezone $TimezoneName not found!" -ForegroundColor Yellow
    }
    
    Disconnect-PnPOnline
}
This script changes time zone for all onedrive for business site collection in the tenant!

Here is the list of Time zones available (Retrieved with: $Web.RegionalSettings.TimeZones)
Timezone Id Description
2 (UTC) Dublin, Edinburgh, Lisbon, London
3 (UTC+01:00) Brussels, Copenhagen, Madrid, Paris
4 (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
5 (UTC+02:00) Athens, Bucharest
6 (UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
7 (UTC+02:00) Minsk (old)
8 (UTC-03:00) Brasilia
9 (UTC-04:00) Atlantic Time (Canada)
10 (UTC-05:00) Eastern Time (US and Canada)
11 (UTC-06:00) Central Time (US and Canada)
12 (UTC-07:00) Mountain Time (US and Canada)
13 (UTC-08:00) Pacific Time (US and Canada)
14 (UTC-09:00) Alaska
15 (UTC-10:00) Hawaii
16 (UTC+13:00) Samoa
17 (UTC+12:00) Auckland, Wellington
18 (UTC+10:00) Brisbane
19 (UTC+09:30) Adelaide
20 (UTC+09:00) Osaka, Sapporo, Tokyo
21 (UTC+08:00) Kuala Lumpur, Singapore
22 (UTC+07:00) Bangkok, Hanoi, Jakarta
23 (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
24 (UTC+04:00) Abu Dhabi, Muscat
25 (UTC+03:30) Tehran
26 (UTC+03:00) Baghdad
27 (UTC+02:00) Jerusalem
28 (UTC-03:30) Newfoundland
29 (UTC-01:00) Azores
30 (UTC-02:00) Mid-Atlantic
31 (UTC) Monrovia, Reykjavik
32 (UTC-03:00) Cayenne, Fortaleza
33 (UTC-04:00) Georgetown, La Paz, Manaus, San Juan
34 (UTC-05:00) Indiana (East)
35 (UTC-05:00) Bogota, Lima, Quito
36 (UTC-06:00) Saskatchewan
37 (UTC-06:00) Guadalajara, Mexico City, Monterrey
38 (UTC-07:00) Arizona
39 (UTC-12:00) International Date Line West
40 (UTC+12:00) Fiji
41 (UTC+11:00) Solomon Is., New Caledonia
42 (UTC+10:00) Hobart
43 (UTC+10:00) Guam, Port Moresby
44 (UTC+09:30) Darwin
45 (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
46 (UTC+07:00) Novosibirsk
47 (UTC+05:00) Tashkent
48 (UTC+04:30) Kabul
49 (UTC+02:00) Cairo
50 (UTC+02:00) Harare, Pretoria
51 (UTC+03:00) Moscow, St. Petersburg, Volgograd
53 (UTC-01:00) Cabo Verde
54 (UTC+04:00) Baku
55 (UTC-06:00) Central America
56 (UTC+03:00) Nairobi
57 (UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb
58 (UTC+05:00) Ekaterinburg
59 (UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
60 (UTC-03:00) Greenland
61 (UTC+06:30) Yangon (Rangoon)
62 (UTC+05:45) Kathmandu
63 (UTC+08:00) Irkutsk
64 (UTC+07:00) Krasnoyarsk
65 (UTC-04:00) Santiago
66 (UTC+05:30) Sri Jayawardenepura
67 (UTC+13:00) Nuku'alofa
68 (UTC+10:00) Vladivostok
69 (UTC+01:00) West Central Africa
70 (UTC+09:00) Yakutsk
71 (UTC+06:00) Astana
72 (UTC+09:00) Seoul
73 (UTC+08:00) Perth
74 (UTC+03:00) Kuwait, Riyadh
75 (UTC+08:00) Taipei
76 (UTC+10:00) Canberra, Melbourne, Sydney
77 (UTC-07:00) Chihuahua, La Paz, Mazatlan
78 (UTC-08:00) Baja California
79 (UTC+02:00) Amman
80 (UTC+02:00) Beirut
81 (UTC-04:00) Cuiaba
82 (UTC+04:00) Tbilisi
83 (UTC+01:00) Windhoek
84 (UTC+04:00) Yerevan
85 (UTC-03:00) Buenos Aires
86 (UTC) Casablanca
87 (UTC+05:00) Islamabad, Karachi
88 (UTC-04:30) Caracas
89 (UTC+04:00) Port Louis
90 (UTC-03:00) Montevideo
91 (UTC-04:00) Asuncion
92 (UTC+12:00) Petropavlovsk-Kamchatsky - Old
93 (UTC) Coordinated Universal Time
94 (UTC+08:00) Ulaanbaatar
95 (UTC-11:00) Coordinated Universal Time-11
96 (UTC-02:00) Coordinated Universal Time-02
97 (UTC+12:00) Coordinated Universal Time+12
98 (UTC+02:00) Damascus
99 (UTC+10:00) Magadan
100 (UTC+02:00) Kaliningrad
101 (UTC+03:00) Istanbul
102 (UTC+06:00) Dhaka
103 (UTC-03:00) Salvador
104 (UTC+02:00) E. Europe
106 (UTC+04:00) Izhevsk, Samara
107 (UTC+11:00) Chokurdakh
108 (UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky
109 (UTC+03:00) Minsk
110 (UTC+04:00) Astrakhan, Ulyanovsk
111 (UTC+07:00) Barnaul, Gorno-Altaysk
112 (UTC+07:00) Tomsk
114 (UTC+11:00) Sakhalin
115 (UTC+06:00) Omsk
OneDrive for Business: Change Time Zone using PowerShell OneDrive for Business: Change Time Zone using PowerShell Reviewed by Salaudeen Rajack on April 09, 2019 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.