OneDrive for Business:使用 PowerShell 更改时区
要求:更改 OneDrive for Business 网站的时区。
如何设置 OneDrive for Business 时区?
租户的默认区域和时区是您在注册时选择组织所在区域时设置的,并且一旦设置就无法更改。如果您注意到,OneDrive 站点默认时区设置为“(UTC-08:00) 太平洋时间(美国和加拿大)”。这导致“创建”、“修改时间”等日期字段值不一致,许多用户开始抱怨他们的时区设置不正确! 您可能想要更改 OneDrive 网站的时区。作为 OneDrive 的所有者,您可以使用以下说明更改 OneDrive 网站的时区。
- 登录 Office 365 并转到您的 OneDrive 站点。通常,位于 https://tenant-my.sharepoint.com/personal/YOUR_LOGIN_ID
在屏幕右上角,单击齿轮图标,然后从菜单中选择“OneDrive 设置”。
- 在“站点设置”页面中,单击左侧导航中的“更多设置”>> 单击“区域设置”链接
在区域设置页面上,时区设置位于页面顶部。使用下拉菜单根据您的要求更改时区。单击底部的“确定”按钮保存更改。
完成后,OneDrive 中文件的时间戳将更改以匹配新区域。
使用 PowerShell 更改 OneDrive 时区
虽然用户可以为其 OneDrive 站点设置时区,但作为管理员,您可以使用 PowerShell 设置所有 OneDrive for Business 站点的时区。
#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
}
}
此脚本更改租户中所有 OneDrive for Business 网站集的时区!以下是可用时区的列表(通过 $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 |

