此为历史版本和 IPFS 入口查阅区,回到作品页
Phanix
IPFS 指纹 这是什么

作品指纹

Microsoft 365 / Sharepoint 更改 domain name

Phanix
·
·
紀錄一下把 Microsoft 365 / Sharepoint 網站更改 domain name的方式。會需要做這件事情通常跟公司更換 brand name,或者成立新公司等狀況會發生,主要是為了使企業識別一致化。

參考資料

基本上按照這兩篇
learn.microsoft.com/...

learn.microsoft.com/...
操作就可以,但是人生總有遇到奇奇怪怪的事情的時候

前置作業

需要先從 Microsoft 365 Admin 裡頭先增加 NEW_DOMAIN, 並把 OLD_DOMAIN 改為備援,步驟可以參考前面兩個連結。

> Connect-SPOService -Url "https://OLD_DOMAIN-admin.sharepoint.com"

上面這個步驟會需要做帳號登入驗證,需要有sharepoint admin 權限(最好是整個 365 的 admin 權限)。

排程更改 domain name

> Start-SPOTenantRename -DomainName "NEW_DOMAIN" -ScheduledDateTime "YYYY-MM-DDThh:ii:ss"

我下command 的時候是 2025-07-19T23:xx:xx ,排程預定2025-07-20T12:32:00 執行

> Start-SPOTenantRename -DomainName "NEW_DOMAIN" -ScheduledDateTime "2025-07-20T12:32:00"

結果沒想到出現訊息如下

警告: 請確認您已認真閱讀 [SPO 租用戶重新命名] 並瞭解其對貴組織的影響 https://aka.ms/SPOTenantRename 。
確認
確定要執行此動作?
Performing the operation "Start-SPOTenantRename."
[Y] 是(Y) [A] 全部皆是(A) [N] 否(N) [L] 全部皆否(L) [S] 暫停(S) [?] 說明 (預設值為 "Y"): y
CorrelationId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Start-SPOTenantRename : Error Code: -772,排程日期/時間必須在未來24小時內。
位於 線路:1 字元:1
+ Start-SPOTenantRename -DomainName "NEW_DOMAIN" -ScheduledDateTime "2025 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-SPOTenantRename],Exception
+ FullyQualifiedErrorId : Error Code: -772,排程日期/時間必須在未來24小時內。,Microsoft.Online.SharePoint.PowerShell
.StartSPOTenan tRename

嘗試修改多次時間之後依然會跳出 排程日期/時間必須在未來24小時內 訊息。

期間甚至還認為是不是時區問題,而嘗試將將排程時間做成變數。

> $scheduledTime = (Get-Date).AddHours(19)> echo $scheduledTime> Start-SPOTenantRename -DomainName "NEW_DOMAIN" -ScheduledDateTime $scheduledTime

解決方式

後來努力搜尋了網路加上配合詢問 grok.com 之後才得到答案。而且奇妙的是 grok.com 如果是用快速回覆,沒有深度搜尋的話結果一樣是錯的。

根據 learn.microsoft.com/...

Specifies the date-time that the job will be started. This should be at least 24 hours in the future, but no more than 30 days.

所以顯然是power shell回應錯誤訊息的中文翻譯有問題,不應該為排程日期/時間必須在未來24小時內

上述網址的中文版,翻譯其實也不太精確,仍然有機會被誤導。learn.microsoft.com/...

最後把時間指定在 24 hrs 後就沒問題了。

> Start-SPOTenantRename -DomainName "NEW_DOMAIN" -ScheduledDateTime 2025-07-22T02:41:41警告: 請確認您已認真閱讀 [SPO 租用戶重新命名] 並瞭解其對貴組織的影響 https://aka.ms/SPOTenantRename。確認確定要執行此動作?Performing the operation "Start-SPOTenantRename."[Y] 是(Y)  [A] 全部皆是(A)  [N] 否(N)  [L] 全部皆否(L)  [S] 暫停(S)  [?] 說明 (預設值為 "Y"): y成功RenameJobID : oooooooo-oooo-oooo-oooo-oooooooooooo

事後可以用 Get-SPOTenantRenameStatus 去檢查更新 domain name 狀態

> Get-SPOTenantRenameStatusRenameJobId     : oooooooo-oooo-oooo-oooo-ooooooooooooStatus          : QueuedRequested at    : xxxxxxxxxxxxxxxxxxxxx (UTC)Requested by    : admin@OLD_DOMAINScheduled at    : xxxxxxxxxxxxxxxxxxxxx (UTC)New domain name : NEW_DOMAINTotal sites     : 86Please wait while we fetch the progress of the rename. This could take a few minutes.In progress        : 0Renamed            : 0Attention required : 0
> Get-SPOTenantRenameStatusRenameJobId     : oooooooo-oooo-oooo-oooo-ooooooooooooStatus          : QueuedRequested at    : xxxxxxxxxxxxxxxxxxxxx (UTC)Requested by    : admin@OLD_DOMAINScheduled at    : xxxxxxxxxxxxxxxxxxxxx (UTC)New domain name : NEW_DOMAINTotal sites     : 86Please wait while we fetch the progress of the rename. This could take a few minutes.In progress        : 0Renamed            : 86Attention required : 0

順利完成的話可以看到全部 site 都已經 Renamed。

CC BY-NC-ND 4.0 授权