SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
将创建好的content type(若是跨web application需要事先publish content type,并在Monitor中跑和Content type同步相关的job,这里我写好了一个脚本,一键执行所有和content type相关的jobs)添加到指定的SharePoint list中,代码如下(以下代码保存到桌面“AddCTToList.ps1”文件中):
Add-PSSnapin Microsoft.SharePoint.PowerShell function AddCTToList()
{
$webUrl = Read-Host "Enter the web url"
$web = Get-SPWeb $webUrl
$ListTitle = Read-Host "Enter the list title"
$List = $web.Lists[$ListTitle]
if ($List -ne $null)
{
$List.ContentTypesEnabled = $true
$List.Update()
$CTName = Read-Host "Enter the content type name"
$CT = $web.ContentTypes[$CTName]
$List.ContentTypes.Add($CT)
$List.Update()
Write-Host "Content type " $CT.Name " added to list " $ListTitle -ForegroundColor Green
}
else
{
Write-Host "The list " $ListTitle " does not exist in site " $web.Title
}
} AddCTToList
按提示先后输入:站点的url,list的title,content type的名字。调用方法如下:
运行结果如下:
之后在SharePoint中相应list的list setting页面我们可以看到,content type已经成功加入:
SharePoint自动化系列——Add content type to list.的更多相关文章
- SharePoint自动化系列——Add/Remove "Record" from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 目的:批量的将SharePoint items变成records或者将records变成普通的it ...
- SharePoint自动化系列——Add/Remove “Hold” from items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题1: 1.如果SharePoint item被添加了hold,通过UI界面来对SharePoi ...
- SharePoint自动化系列——Content Type相关timer jobs一键执行
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...
- SharePoint自动化系列——Error features自动deactivate
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ SharePoint Content Deployment prerequisite——Error ...
- SharePoint自动化系列——Site/Web/List级别的导航菜单
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...
- SharePoint自动化系列——Create a local user and add to SharePoint
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...
- SharePoint自动化系列——通过Coded UI录制脚本自动化创建SharePoint Designer Reusable Workflow
Coded UI非常好,我开始还在想,怎么样能让一个通过SharePoint Designer创建的Workflow publish三百五十次?想不到一个好的方法,也不知道SharePoint Des ...
- SharePoint自动化系列——创建MMS terms
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Lists
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
随机推荐
- 显示和隐藏Mac下的 隐藏文件
显示:defaults write com.apple.finder AppleShowAllFiles -bool true隐藏:defaults write com.apple.finder Ap ...
- 转:python webdriver API 之调用 JavaScript
当 webdriver 遇到没法完成的操作时,笔者可以考虑借用 JavaScript 来完成,比下下面的例子,通过 JavaScript 来隐藏页面上的元素.除了完成 webdriver 无法完成的操 ...
- 01分数规划poj2728(最优比例生成树)
Desert King Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 21766 Accepted: 6087 Desc ...
- poj 1417(并查集+简单dp)
True Liars Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2087 Accepted: 640 Descrip ...
- [转]Web程序员必须知道的 Console 对象里的九个方法
一.显示信息的命令 01 1: <!DOCTYPE html> 02 2: <html> 03 3: <head> 04 4: <title&g ...
- HDU 3691 Nubulsa Expo(全局最小割Stoer-Wagner算法)
Problem Description You may not hear about Nubulsa, an island country on the Pacific Ocean. Nubulsa ...
- kafka监控工具kafkaOffsetMoniter的使用
简介 KafkaOffsetMonitor是由Kafka开源社区提供的一款Web管理界面,用来实时监控Kafka的Consumer以及Partition中的Offset,可以在web界面直观的看到每个 ...
- js 获取选中的多选框
前台html <span class="spbox"> <input type="checkbox" name="category& ...
- sql 中英文格式的时间转数字格式
select receiveBillDt,CONVERT(varchar(100), cast(receiveBillDt as datetime), 21),a.LoanDate from Prot ...
- linux抓包方法
tcpdump -i eth0 -X -w data.cap 得到的包保存到本地wireshark解析ip.addr == url && http.request.url contai ...