Hi 各位前輩
最近主管發現OneDrive所有使用者的預設時區都是UTC-8
所以小弟上網找了Script要批量修改所有User的時區為UTC+8
#Set Parameters
$AdminSiteURL="https://domain-admin.sharepoint.com"
$TimezoneName = "(UTC+08:00) Taipei"
#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
}
#Read more: https://www.sharepointdiary.com/2019/04/onedrive-for-business-change-timezone-using-powershell.html#ixzz7IInjLDdG
用戶約為200人
腳本的驗證是用全域管理員權限 我也勾了SharePoint管理員
但結果只有一半的使用者成功修改了時區
另一半使用者都會跳出以下結果
已經確定登入的帳號有管理權限了
但是還是無法理解為什麼部分人修改時區還是失敗
你短時間內一次改太多,被當成攻擊行為擋下來...
隔一段時間再改看看, 或者一次改十個人左右就好;
如果還是不行, 請發 Support Ticket 請微軟放寬限制...