Domanda

I am using the Microsoft.SharePoint.Client CSOM Library for PowerShell to automate some site activities against SharePoint.

Almost everything I am doing works except this one section. I am trying to update the time format from 12hr to 24hr and change the working day start and end times.

$Regional = $ClientContext.Web.RegionalSettings

$Regional.Time24 = $True
$Regional.WorkDayStartHour = "540"
$Regional.WorkDayEndHour = "1020"

Try {
    $Regional.Update()
    $ClientContext.ExecuteQuery()
    Write-Host "Successfully set regional settings on subsite." -ForegroundColor Black -BackgroundColor Green
} 

Catch {
Write-Host "Unable to set regional settings on subsite." -ForegroundColor White -BackgroundColor Red
}

SharePoint takes the command okay but I get the response 'Time24 is a ReadOnly property', 'WorkDayStartHour' is a ReadOnly property, 'WorkDayEndHour' is a ReadOnly property.

Is the problem that Web.RegionalSettings displays the settings but doesn't support update and if so, what class do I need to execute against to be able to update?

È stato utile?

Soluzione

Ability to set RegionalSettings via CSOM is now available in Dec 2014 CU.

See here for an example: https://github.com/OfficeDev/PnP/tree/master/Samples/Core.Settings.LocaleAndLanguage

Unfortunately it appears that only the Locale (and not other Regional Settings properties) can be set after DEC 2014 CU. I'm surprised they went to the effort to update the API and only addressed 1 property...doh.

Altri suggerimenti

According To Microsoft's documentation on the RegionalSettings opbject, all properties only have a get method and thus are readonly. See the link below.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.regionalsettings_members(v=office.15).aspx

I'm also looking for a way to update the regionalsettings via code, in my case for a SharePoint online environment. Unfortunately, I didn't find one, other than doing it manually in the UI :(

Currently this is not possible via CSOM. One workaround is to sett the correct locale settings in a Site Collection (via GUI) and then create sites in that Site Collection. All Sites created in a Site Collection "inherit" the Regional settings of the RootWeb.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top