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 are set when you select your organization’s region at the time of registering, and this cannot be changed once it is set. If you noticed, the OneDrive site default timezone is set to “(UTC-08:00) Pacific Time (the 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 the timezone of your OneDrive site. As an owner of your OneDrive, you can use the instructions below to change the timezone of your OneDrive site.
- Logon to Office 365 and go to your OneDrive site. Typically, at https://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.
- 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 are located at the top of the page. Use the drop-down menu to change the time zone as per your requirements. Click on the “OK” button at the bottom to save your changes.
Once you are done, Timestamps on files in your OneDrive will be changed to match the new zone.
Change OneDrive Timezone using PowerShell
While your users can set the timezone for their OneDrive sites, As an Administrator, you can set the 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
}
}
This script changes the 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 |
Hello and thank you for the script. Question: when new accounts (i.e. new employees) are added to the tenant, does this script update their ODBs automatically as they are created or does it need to be rerun to include the new ODBs?
Well, this script only changes the timezone for existing OneDrive sites. For new sites (including SharePoint and OneDrive), You can set the default timezone under “Site Creation” Settings in SharePoint Admin Center. More here: SharePoint Online: How to Change Time Zone using PowerShell?
Does this Powershell change the time zone for new accounts as their profile is being created and their ODB set up or is it just retoractive and updates only existing ODBs (which would mean this script would have to be run multiple times)?
This seems to require that your O365 administrator has rights to each OneDrive as well. This can also probably be done through Powershell or GUI, but it would be nice to add it right to this script. Without going into each individual’s OneDrive and adding your Administrator as a Site admin of every single user – this script will just not work, it seems!
Exactly! Having Office 365 Admin or SharePoint Online Admin roles doesn’t gain you Admin rights to OneDrive when you access it through PowerShell (Although you can access any user’s OneDrive through Microsoft Admin Center!). You must add your account to each OneDrive site. Here is the PowerShell script to help: How to Gain Admin Access to All OneDrive Sites using PowerShell?
I ran this as Global Admin of my O365 Tenant and i received this error and the Timezones are untouched.
Do you have any Recommendations for me ?
Invoke-PnPQuery : There is currently no connection yet. Use Connect-PnPOnline to connect.
In Zeile:33 Zeichen:9
Invoke-PnPQuery
~~~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Invoke-PnPQuery], InvalidOperationException
FullyQualifiedErrorId : System.InvalidOperationException,PnP.PowerShell.Commands.Base.InvokeQuery
Hi, do you have one supported by importing from txt or csv file? It gives better control. Thanks!