I would like to update regional settings (TimeZone to be exact) in 1000 sites.

I found the right property $ctx.Web.RegionalSettings.TimeZone, but it is read-only. I searched for any functions allowing to modify the TimeZone, but did not find any (no TimeZones.Add() or .SetAsDefault()).

  1. Manual change is not an option.
  2. LocaleID is not the same as TimeZone. Please do not offer solutions to change LocaleID.
  3. There are no issues connecting to SPO or reading data. I can retrieve/read the current Zone with code:

13 (UTC-08:00) Pacific Time (US and Canada)

Question
How can I update $ctx.Web.RegionalSettings.TimeZone for 1000 sites using code?

有帮助吗?

解决方案

The answer is to set TimeZone as a TimeZone:

 $ctx.Load($ctx.Web)
 $ctx.Load($ctx.Web.RegionalSettings.TimeZone)
 $ctx.Load($ctx.Web.RegionalSettings.TimeZones)
 $ctx.ExecuteQuery()    


   $ctx.Web.RegionalSettings.TimeZone=$ctx.Web.RegionalSettings.TimeZones.GetbyID($TimeZoneID)
$ctx.Web.Update()
$ctx.ExecuteQuery()

The answer comes from the amazing Vesa Juvonen and his blog: http://blogs.msdn.com/b/vesku/archive/2015/04/10/new-sharepoint-csom-version-released-for-office-365.aspx

许可以下: CC-BY-SA归因
scroll top