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组中, ...
随机推荐
- HTML部分标签和代码
1.1.1 一般标签.格式控制标签 所谓HTML就是 Hyper Text Markup Language(超无文本标记语言) <html> 开始标签 <head> 网页上 ...
- 如何抠PSD素材中的图片
在网上经常可以找到一些好看呢的PSD素材,如何才能将这些素材抠出来 存成一张张的png图片呢? 在PhotoShop中 1·隐藏无用的图层,然后窗口中仅剩需要看到的那个素材图 2·用工具选择该区域(注 ...
- html 标签内部元素上下居中
<div style="width: 200px; height: 200px; border: 1px solid red; line-height: 200px;"> ...
- FOJ 2013 11 月赛
这套题目还是比较吊的,由于我的沙茶,还是很多没有做出来- -! C:逆序数 D:呵呵 A:妈蛋,自己精度没弄好,想到之前GCC的要加eps,就WA了几次后交Visual C++过了!C(n,m)p^m ...
- Python学习总结18:函数 参数篇
1. 判断函数是否可调用 >>> import math >>> x = 1 >>> y = math.sqrt >>> cal ...
- the serializable class XXX does not declare a static final seriaVersionUID...的问题
关于myeclips提示The serializable class XXX does not declare a static final serialVersionUID field of typ ...
- Android自定义ScrollView实现一键置顶功能
效果图如下: (ps:动态图有太大了,上传不了,就给大家口述一下要实现的功能吧) 要实现的功能:当ScrollView向上滑动超过一定距离后,就渐变的出现一个置顶的按钮,当滑动距离小于我们指定的距离时 ...
- 使用sudo执行命令的时候提示找不到命令
事出有因, 源自使用源码编译 nginx , 在 /usr/local/sbin/ 目录下创建了nginx 启动的符号链接 , 执行 sudo nginx 的时候提示找不到命令, 但是使用普通用户身份 ...
- 【fedora】设置fedora系统
1.安装自动选择最快源的插件fastestmirror: #sudo yum -y install axel yum-plugin-fastestmirror && sudo yum ...
- Visual studio 中编译错误SQL71006: Only one statement is allowed per batch. A batch separator, such as 'GO', might be required between statements.
把写好的sql脚本,并在mssqlmanager里面编译成功的存储过程脚本复制到vs项目下,出现错误信息如下:SQL71006: Only one statement is allowed per b ...