Powershell CSOM更新了sharepoint主题错误 [英] Powershell CSOM update sharepoint theme errors wierdly

查看:104
本文介绍了Powershell CSOM更新了sharepoint主题错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我尝试将SharePoint网站上的主题更新为Green。公司颜色非常接近。无论如何,代码运行完美。但是这个网站很糟糕。



我可以把它恢复到我需要的状态但是我需要这个代码才能工作。我有大约500个SharePoint网站要更新,这只是失败。



URL改为保护无辜(ME)



大象b after后的样子。 Rod:Borked SharePoint网站?任何人? [ ^ ]



So I am trying to update the theme on the SharePoint site to Green. Company colors pretty close. Anyway, the code runs flawlessly. But borks the site badly.

I can get it back to what I need but I need this code to work. I have around 500 SharePoint sites to update and well this is just failing.

URL changed to protect the innocent (ME)

What it looks like after the elephant borkings. Rod: Borked SharePoint site? Anyone?[^]

<pre lang="text">

代码示例。

[System.Reflection.Assembly] :: LoadWithPartialName(Microsoft.SharePoint.Client)

[System.Reflection.Assembly] :: LoadWithPartialName(Microsoft.SharePoint.Client.Runtime )

[System.Reflection.Assembly] :: LoadWithPartialName(Microsoft.SharePoint.Client.SharePointOnlineCredentials)



$ tempC = new-object System.Net.WebClient

$ tempC.UseDefaultCredentials = $ true

$ Ctx = New-Object Microsoft.SharePoint.Client.ClientContext(http:// bergren.net/)

$ Ctx.Credentials = $ tempC.Credentials



#Get the web

$ Web = $ Ctx.web

$ Ctx.Load($ Web)

$ Ctx.ExecuteQuery()



#Frame主页面URL

$ MasterPageURL =$($ web.ServerRelativeUrl)/ _ catalogs / masterpage / seattle.master



#Set Default Master page &安培;自定义母版页

$ web.CustomMasterUrl = $ MasterPageURL

$ Web.MasterUrl = $ MasterPageURL

$ web.Update()

$ Ctx.ExecuteQuery()



$ fontSchemeUrl =$($ web.ServerRelativeUrl)/ _ catalogs / theme / 15 / fontscheme003.spfont< br $>
$ themeurl =$($ web.ServerRelativeUrl)/ _ catalogs / theme / 15 / Palette013.spcolor

$ imageUrl =$($ web.ServerRelativeUrl)/ _ layouts /15/images/siteIcon.png?rev=23



$ web.ApplyTheme($ themeurl,$ fontSchemeUrl,$ imageUrl,$ false)

$ web.Update()

$ Ctx.ExecuteQuery()



我的尝试:



我已经搞乱了很多代码。我也在SharePoint服务器上尝试过服务器端代码,它们几乎做同样的事情。一切都看起来像这样。

Code Example.
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.SharePointOnlineCredentials")

$tempC = new-object System.Net.WebClient
$tempC.UseDefaultCredentials=$true
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext("http://bergren.net/")
$Ctx.Credentials=$tempC.Credentials

#Get the Web
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()

#Frame Master page URL
$MasterPageURL = "$($web.ServerRelativeUrl)/_catalogs/masterpage/seattle.master"

#Set Default Master page & Custom Master page
$web.CustomMasterUrl = $MasterPageURL
$Web.MasterUrl = $MasterPageURL
$web.Update()
$Ctx.ExecuteQuery()

$fontSchemeUrl = "$($web.ServerRelativeUrl)/_catalogs/theme/15/fontscheme003.spfont"
$themeurl = "$($web.ServerRelativeUrl)/_catalogs/theme/15/Palette013.spcolor"
$imageUrl = "$($web.ServerRelativeUrl)/_layouts/15/images/siteIcon.png?rev=23"

$web.ApplyTheme($themeurl, $fontSchemeUrl, $imageUrl, $false)
$web.Update()
$Ctx.ExecuteQuery()

What I have tried:

I have messed with the code alot. I have also tried Server side code on the SharePoint servers that pretty much do the same thing. Everything ends up looking like this.

推荐答案

tempC = new-object System.Net.WebClient
tempC = new-object System.Net.WebClient


tempC .UseDefaultCredentials =
tempC.UseDefaultCredentials=


true
true


这篇关于Powershell CSOM更新了sharepoint主题错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆