SharePoint自动化系列——创建MMS terms
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
PowerShell脚本实现MMS group、termSet、terms的自动化创建:
Add-PSSnapin Microsoft.SharePoint.PowerShell
function CreateTerms{
param($siteUrl,$groupName,$termSetName,$termsCount)
#Connect to the Metadata Service
$taxSite = Get-SPSite $siteUrl
$taxonomySession = Get-SPTaxonomySession -site $taxSite
$termStore = $taxonomySession.TermStores["Managed Metadata Service"]
$flag = $true
foreach($group in $termStore.Groups)
{
if($group.name -eq $groupName)
{
Write-Warning "Group exists."
$flag = $false
}
}
if($flag -eq $true)
{
$termGroup = $termStore.CreateGroup($groupName)
$termStore.CommitAll()
}else
{
$termGroup = $termStore.Groups[$groupName]
}
$flag = $true
foreach($termSet in $termGroup.termSets)
{
if($termSet.name -eq $termSetName)
{
Write-Warning "TermSet exists."
$flag = $false
}
}
if($flag -eq $true)
{
$termSet = $termGroup.createTermSet($termSetName)
$termStore.CommitAll()
}else
{
$termSet = $termGroup.termSets[$termSetName]
}
for($i=1;$i -le $termsCount;$i++)
{
try{
$termSet.CreateTerm("Term"+$i,1033)
$termStore.CommitAll()
}catch
{
Write-Warning "Term exists."
}
}
Read-Host
}
CreateTerms -siteUrl http://xxxx -groupName xxxx -termSetName xxxx -termsCount xx
脚本保存到ps1文件,在server上右键run with PowerShell即可。
实现:在Managed Metadata Service这个service application下创建指定名字的Group,Termset以及指定数量的Terms。如果有同名情况出现会提示相应内容已存在,不会重复创建:

SharePoint自动化系列——创建MMS terms的更多相关文章
- SharePoint自动化系列——Set MMS field value using PowerShell.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 本章将总结一下设置SharePoint list中item的Managed Metadata fi ...
- SharePoint自动化系列——Site/Web/List级别的导航菜单
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...
- SharePoint自动化系列——通过Coded UI录制脚本自动化创建SharePoint Designer Reusable Workflow
Coded UI非常好,我开始还在想,怎么样能让一个通过SharePoint Designer创建的Workflow publish三百五十次?想不到一个好的方法,也不知道SharePoint Des ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Web
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Site Collection
通过PowerShell创建SharePoint Site Collection,代码如下: Add-PSSnapin microsoft.sharepoint.powershell function ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Lists
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——通过PowerShell创建SharePoint List Items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Create a local user and add to SharePoint
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...
随机推荐
- codeforces-Glass Carving(527C)std::set用法
C. Glass Carving time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- 【Origin】羡旁人
-道行至一桥畔,微风轻抚,观河岸杨柳柳枝空舞,看满路车辆畅行无阻,虽羡,然各有归途. 小河岸,棵棵杨柳,柳枝随风摆; 大路上,盏盏绿灯,一路往北开. 横批: 可惜不是我 -作于二零一六年三月二十二日
- [原创]java WEB学习笔记50:文件上传案例
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- C#: 启动画面设计
Windows Form经常会在启动主界面的时候预先有启动画面,这也是因为用户体验的需要,用户知道已经启动application,而不是在load resource的时候等待.因此这里不能用单线程的思 ...
- const修饰
const int A() //const // ====>int A(const this) { //观点1:const是修饰a,但是通过测试,我们发现,b++也不能编译通过 //这说明:co ...
- HDU 4513 吉哥系列故事——完美队形II(Manacher)
Problem Description 吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h[1], h[2] ... h[n],吉哥希望从中挑出一些人,让这些人形成 ...
- ARM 寄存器的介绍
ARM 寄存器 31个通用, 32个程序状态寄存器 怎么算的呢: (R0--R15) 16 + 7 + 8 =31 通用 程序状态寄存器: 6 个 共 37 个. 不分组寄存器: ...
- 验证你的邮箱是不是qq邮箱
Console.WriteLine("请输入你的qq邮箱"); string yx = Console.ReadLine(); int a = yx.LastIndexOf(&qu ...
- paper 30 :libsvm的参数说明
English: libsvm_options: -s svm_type : set type of SVM (default 0) 0 -- C-SVC 1 -- nu-SVC 2 -- one-c ...
- 4项技巧使你不再为PHP中文编码苦恼
PHP程序设计中中文编码问题曾经困扰很多人,导致这个问题的原因其实很简单,每个国家(或区域)都规定了计算机信息交换用的字符编码集,如美国的扩展 ASCII 码,中国的 GB2312-80,日本的 JI ...