@AllenXu-MSFT , thanks for your comment.
Hello everyone, sorry for the delay in responding. I couldn't do it this way and identified that PnP -Interactive will no longer be available. So I decided to test it another way, using the following scripts:
# Set Parameters
$AdminSiteURL="https://TENANT-admin.sharepoint.com"
$SiteCollAdmin="TENANTADMIN.onmicrosoft.com"
# Connect to PnP Online to the Tenant Admin Site
Connect-PnPOnline -Url $AdminSiteURL -UseWebLogin
# Get All OneDrive Sites
$OneDriveSites = Get-PnPTenantSite -IncludeOneDriveSites -Filter "Url -like '-my.sharepoint.com/personal/'"
# Loop through each site
ForEach($Site in $OneDriveSites)
{
# Add Site collection Admin
Set-PnPTenantSite -Url $Site.URL -Owners $SiteCollAdmin
Write-Host -f Green "Added Site Collection Admin to: "$Site.URL
}
Responsible for granting admin access to all OneDrives. And after that, I ran this script:
# Register EntraIDAPP PNP
Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "PnP Rocks" -Tenant tenant.onmicrosoft.com -Interactive
# Set Parameters
$AdminSiteURL = "https://TENANT-admin.sharepoint.com"
$LanguageID = 1046 # Portuguese (Brazil)
$TimezoneId = 8 # UTC-03:00 Brasília
$LocaleId = 1046 # Portuguese (Brazil)
$ClientId = "CLIENTID"
# Connect to PnP Online using the registered application
Connect-PnPOnline -Url $AdminSiteURL -Interactive -ClientId $ClientId
# 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 -ForegroundColor Yellow "Processing Site: $($Site.Url)"
# Connect to OneDrive for Business Site
Connect-PnPOnline -Url $Site.Url -Interactive -ClientId $ClientId
# Get the Web
$Web = Get-PnPWeb -Includes RegionalSettings.TimeZones
# Configure the site as multilingual
$Web.IsMultilingual = $True
$Web.AddSupportedUILanguage($LanguageID)
# Get the desired time zone
$Timezone = $Web.RegionalSettings.TimeZones | Where-Object { $_.Id -eq $TimezoneId }
If ($Timezone -ne $Null) {
# Update the site's time zone
$Web.RegionalSettings.TimeZone = $Timezone
Write-Host -ForegroundColor Green "Timezone Updated Successfully!"
} else {
Write-Host -ForegroundColor Yellow "Timezone ID $TimezoneId not found!"
}
# Update the site's locale
$Web.RegionalSettings.LocaleId = $LocaleId
# Update the Web object
$Web.Update()
Invoke-PnPQuery
}
To set 24-hour time format for each user:
# Set Parameters
$AdminSiteURL = "https://TENANT-admin.sharepoint.com"
$LanguageID = 1046 # Portuguese (Brazil)
$TimezoneId = 8 # UTC-03:00 Brasília
$LocaleId = 1046 # Portuguese (Brazil)
$ClientId = "CLIENTID"
# Connect to PnP Online using the registered application
Connect-PnPOnline -Url $AdminSiteURL -Interactive -ClientId $ClientId
# 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 -ForegroundColor Yellow "Processing Site: $($Site.Url)"
# Connect to OneDrive for Business Site
Connect-PnPOnline -Url $Site.Url -Interactive -ClientId $ClientId
# Get the Web
$Web = Get-PnPWeb -Includes RegionalSettings.TimeZones
# Configure the site as multilingual
$Web.IsMultilingual = $True
$Web.AddSupportedUILanguage($LanguageID)
# Get the desired time zone
$Timezone = $Web.RegionalSettings.TimeZones | Where-Object { $_.Id -eq $TimezoneId }
If ($Timezone -ne $Null) {
# Update the site's time zone
$Web.RegionalSettings.TimeZone = $Timezone
Write-Host -ForegroundColor Green "Timezone Updated Successfully!"
} else {
Write-Host -ForegroundColor Yellow "Timezone ID $TimezoneId not found!"
}
# Update the site's locale
$Web.RegionalSettings.LocaleId = $LocaleId
# Set the time format to 24 hours using PowerShell
$Web.RegionalSettings.Time24 = $True
# Update the Web object
$Web.Update()
Invoke-PnPQuery
}
The OneDrive script was executed using PowerShell ISE and the locale change script was executed using PowerShell 7.4.6.