Good morning all.
I have a dilemma - our SP tenant has been set with UK region, but with US locale. and this causes problems with American date formats etc.
I have run the following PS script to change all sites' locale to UK:
$LocaleId = 2057 # UK
$TimeZoneId = 2 # London
$credentials = Get-Credential
Connect-PnPOnline https://tenant.sharepoint.com/sites/yoursite -Credentials $credentials
$sites=Get-PnPTenantSite
foreach($site in $sites){
Connect-PnPOnline $site.Url -Credentials $credentials
$web = Get-PnPWeb -Includes RegionalSettings,RegionalSettings.TimeZones
$timeZone = $web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $TimeZoneId}
$web.RegionalSettings.LocaleId = $LocaleId
$web.RegionalSettings.TimeZone = $timeZone
$web.Update()
Invoke-PnPQuery
}
The script changed SP sites to UK locale, but all OneDrive sites came as "Access Denied" because of unique permissions.
So I was thinking the solution is to add the account running the script as secondary admin to users OneDrive sites, run the above script and remove the secondary admin account at the end of the script and leave the original permissions to all sites.
Adding to the script above something as:
#Store 2nd Admin account into a variable
$adminAcctToAdd = "[email protected]"
#Add 2nd Site Collection admin
Set-SPOUser -Site $url.PersonalUrl -LoginName $adminAcctToAdd -IsSiteCollectionAdmin $true
Run the above locale change script and at the end remove the secondary admin:
Set-SPOUser -Site $url.PersonalUrl -LoginName $adminAcctToRemove -IsSiteCollectionAdmin $false
Any help how to bolt that together?
Much appreciated! Best!