存在这样一种情况,对应的page已经部署到product的SharePoint环境中,那么在部署下一个版本的时候就不允许把已经创建好的page删除再创建,因此page中修改过的属性就不能再次部署到SharePoint中。

鉴于这种情况,我们可以手动的在SharePoint环境中修改page的属性(例如:title),也可以编写feature或者PowerShell脚本处理这种修改。

如下便是通过PowerShell脚本修改page的title属性:

#webapp url
$webAppUrl = http://url.../ #web urls
$rootWebUrl = $webAppUrl + "haha"
$rttaWebUrl = $webAppUrl + "haha/rtta"
$supportWebUrl = $webAppUrl + "haha/support" #web pages arrays
$rootWebPages = @("Pages/rootpage1.aspx", "Pages/rootpage2.aspx", "Pages/rootpage3.aspx", "Pages/rootpage4.aspx")
$rttaWebPages = @("Pages/rttapage1.aspx", "Pages/rttapage2.aspx", "Pages/rttapage3.aspx")
$supportWebPages = @("Pages/supportpage1.aspx", "Pages/supportpage2.aspx", "Pages/supportpage3.aspx") #If you don't want to change any page's title in target web. Define variables as following.
#$rootWebPages = ""
#$rttaWebPages = ""
#$supportWebPages = "" #title arrays
$rootWebPagesTitle = @("My Root Page1", "My Root Page2", "My Root Page3", "My Root Page4")
$rttaWebPagesTitle = @("My Page1", "My Page2", "My Page3")
$supportWebPagesTitle = @("Your Page1", "Your Page2", "Your Page3") #
#change target web pages title
#
function ChangeTargetWebPagesTitle([string]$pageType)
{
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Start change target web pages title logic "); if($pageType -eq "root")
{
$webUrl = $rootWebUrl
$webPagesArray = $rootWebPages
$webPagesTitleArray = $rootWebPagesTitle
}
if($pageType -eq "rtta")
{
$webUrl = $rttaWebUrl
$webPagesArray = $rttaWebPages
$webPagesTitleArray = $rttaWebPagesTitle
}
if($pageType -eq "support")
{
$webUrl = $supportWebUrl
$webPagesArray = $supportWebPages
$webPagesTitleArray = $supportWebPagesTitle
} if($webPagesArray.Length -gt 0)
{
$spWeb = Get-SPWeb -Identity $webUrl
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($spWeb))
{
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)
$pages = $spPubWeb.PagesList
foreach($item in $pages.Items)
{
$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
for($i = 0; $i -lt $webPagesArray.Length; $i++)
{
if (($pubPage.Url -eq $webPagesArray[$i]) -and ($pubPage.Title -ne $webPagesTitleArray[$i]))
{
$pubPage.CheckOut()
$pubPage.Title = $webPagesTitleArray[$i]
$pubPage.Update();
$pubPage.CheckIn("")
$pageFile = $pubPage.ListItem.File;
$pageFile.Publish("");
#pageFile.Approve(checkInComment); Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Change title to: " + $webPagesTitleArray[$i]);
break
}
}
}
}
$spWeb.Dispose()
} Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Finish change target web pages title logic ");
} #
#change root web pages title
#
function ChangeRootWebPagesTitle
{
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Start ChangeRootWebPagesTitle Function");
if($rootWebPages.Length -gt 0)
{
ChangeTargetWebPagesTitle("root")
}
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Finish ChangeRootWebPagesTitle Function");
} #
#change rtta web pages title
#
function ChangeRTTAWebPagesTitle
{
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Start ChangeRTTAWebPagesTitle Function");
if($rttaWebPages.Length -gt 0)
{
ChangeTargetWebPagesTitle("rtta")
}
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Finish ChangeRTTAWebPagesTitle Function");
} #
#change support web pages title
#
function ChangeSupportWebPagesTitle
{
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Start ChangeSupportWebPagesTitle Function");
if($supportWebPages.Length -gt 0)
{
ChangeTargetWebPagesTitle("support")
}
Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("Finish ChangeSupportWebPagesTitle Function");
} #call function to change root web pages title
ChangeRootWebPagesTitle
#call function to change rtta web pages title
ChangeRTTAWebPagesTitle
#call function to change support web pages title
ChangeSupportWebPagesTitle Write-Host -BackgroundColor DarkGreen -ForegroundColor White ("================ Finish change the pages title ==================");

。。。。。。。。。。

用PowerShell脚本实现对SharePoint页面Title的修改的更多相关文章

  1. 用 Python 脚本实现对 Linux 服务器的监控

    目前 Linux 下有一些使用 Python 语言编写的 Linux 系统监控工具 比如 inotify-sync(文件系统安全监控软件).glances(资源监控工具)在实际工作中,Linux 系统 ...

  2. 用 Python 脚本实现对 Linux 服务器的网卡流量监控

    *这篇文章网上已经有相关代码,为了加深印象,我做了相关批注,希望对朋友们有帮助 工作原理:基于/proc文件系统 Linux 系统为管理员提供了非常好的方法,使其可以在系统运行时更改内核,而不需要重新 ...

  3. 通过脚本实现对web的健康检查

    前面的文章中(https://www.cnblogs.com/zyxnhr/p/10707932.html),通过nginx的第三方模块实现对web端的一个监控,现在通过一个脚本实现对第三方的监控 脚 ...

  4. Python 脚本实现对 Linux 服务器的监控

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 原文地址 由于原文来自微信公众号,并且脚本都是图片,所以这里 ...

  5. 利用shell脚本实现对mysql数据库的备份

    #!/bin/bash #保存备份个数 number=3 #备份保存路径 backup_dir=/root/mysqlbackup #日期 dd=`date +%Y%m%d` #备份工具 tool=m ...

  6. 用PowerShell脚本删除SharePoint 的 Page中的WebPart

    编写PowerShell脚本可以删除page中所有的webpart,也可以根据webpart的属性信息去删除特定的webpart. 下面的PowerShell脚本便是删除对应page中所有的webpa ...

  7. jmeter通过BeanShell 脚本,实现对http请求参数的加密

    jmeter一直是一款很好的接口和性能测试工具,它是开源的,不需要为此支付任何费用,而且可以下载源码,可以在修改源代码并在此基础上拓展自己的功能或插件,它可以跟ant和jenkins结合起来搭建自己的 ...

  8. 实现对MySQL数据库进行分库/分表备份(shell脚本)

    工作中,往往数据库备份是件非常重要的事情,毕竟数据就是金钱,就是生命!废话不多,下面介绍一下:如何实现对MySQL数据库进行分库备份(shell脚本) Mysq数据库dump备份/还原语法: mysq ...

  9. zabbix实现对tomcat的监控

    zabbix实现对tomcat的监控 工作原理 比如:当Zabbix-Server需要知道java应用程序的某项性能的时候,会启动自身的一个Zabbix-JavaPollers进程去连接Zabbix- ...

随机推荐

  1. Kendo UI

    http://www.cnblogs.com/libingql/category/585455.html http://www.scala-china.net/discuz/forum.php?mod ...

  2. ACM/ICPC 之 BFS范例(ZOJ2913-ZOJ1136(POJ1465))

    通过几道经典BFS例题阐述BFS思路 ZOJ2913-Bus Pass 题意:找一个center区域,使得center到所有公交线路最短,有等距的center则输出id最小的. 题解:经典的BFS,由 ...

  3. 上传文件报错System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。

    在上传文件的时候报错. 错误: System.Net.ProtocolViolationException: 必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetRe ...

  4. Python字符编码

    http://www.runoob.com/python/python-strings.html ASCII Unicode UTF-8 # -*- coding: utf-8 -*- 格式化 %运算 ...

  5. Effective C++ -----条款39:明智而审慎地使用private继承

    Private继承意味is-implemented-in-terms of(根据某物实现出).它通常比复合(composition)的级别低.但是当derived class需要访问protected ...

  6. codeforces 425C Sereja and Two Sequences(DP)

    题意读了好久才读懂....不知道怎么翻译好~~请自便~~~ http://codeforces.com/problemset/problem/425/C 看懂之后纠结好久...不会做...仍然是看题解 ...

  7. Binary String Matching

    问题 B: Binary String Matching 时间限制: 3 Sec  内存限制: 128 MB提交: 4  解决: 2[提交][状态][讨论版] 题目描述 Given two strin ...

  8. BestCoder8 1001.Summary(hdu 4989) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4989 题目意思:给出 n 个数,然后将这些数两两相加,得到 n*(n-1) /2 对和,把重复的和去掉 ...

  9. css 自动换行 [英文、数字、中文]

    white-space:normal;overflow: auto;table-layout:fixed; word-break: break-all;

  10. HTML简历表格

    效果图 <!DOCTYPE > <html> <head> <meta charset="utf-8" /> </head&g ...