转载请注明出自天外归云的博客园: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的更多相关文章

  1. SharePoint自动化系列——Set MMS field value using PowerShell.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 本章将总结一下设置SharePoint list中item的Managed Metadata fi ...

  2. SharePoint自动化系列——Site/Web/List级别的导航菜单

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...

  3. SharePoint自动化系列——通过Coded UI录制脚本自动化创建SharePoint Designer Reusable Workflow

    Coded UI非常好,我开始还在想,怎么样能让一个通过SharePoint Designer创建的Workflow publish三百五十次?想不到一个好的方法,也不知道SharePoint Des ...

  4. SharePoint自动化系列——通过PowerShell创建SharePoint Web

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  5. SharePoint自动化系列——通过PowerShell创建SharePoint Site Collection

    通过PowerShell创建SharePoint Site Collection,代码如下: Add-PSSnapin microsoft.sharepoint.powershell function ...

  6. SharePoint自动化系列——通过PowerShell创建SharePoint Lists

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  7. SharePoint自动化系列——通过PowerShell创建SharePoint List Items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  8. SharePoint自动化系列——Add content type to list.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...

  9. SharePoint自动化系列——Create a local user and add to SharePoint

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...

随机推荐

  1. C++Builder 解决绘图闪动问题

    使用双缓冲 Form->DoubleBuffered = true; Panel->DoubleBuffered = true;

  2. 最长上升子序列(N*log(N))hdu1025

    (HDU1025) Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  3. 自定义FragmentTabHost--实现View重复加载问题

    1,接着上篇的Fragment+FragmentTabHost搭建简单的底部功能切换框架,效果如下: 结果在项目中用到的时候发现Fragment+FragmentTabHost实现的时候每一次切换底部 ...

  4. 【cube】SSAS(分析服务)优化手册

    优化前注意事项 1.数据质量.数据仓库中维度表的数据质量要严格保证.比如店仓的大区.省区.管理城市等属性和店仓代码没有一对多的上下级关系,这样在设计店仓维度时,就无法建立有效的层次结构.这会拖慢查询时 ...

  5. 0422 数学口袋精灵app

    首先要部署这个app项目就是第一步: 一.前提下载并安装JDK 在线图解:手把手教你安装JDK      http://www.lvtao.net/server/windows-setup-jdk.h ...

  6. paper 53 :深度学习(转载)

    转载来源:http://blog.csdn.net/fengbingchun/article/details/50087005 这篇文章主要是为了对深度学习(DeepLearning)有个初步了解,算 ...

  7. Linux下/etc/resolv.conf 会被重新写入

    主要原因是因为安装了network manager,所以在启动后每次都会重写这个文件. 所以需要在network manager->eth0->ipv4->Automatic(DHC ...

  8. django models使用学习记录

    如何更新单个数据 example = User.objects.get(id=1) example.is_acitve=1 example.save() 如何更新多个数据 examples = Use ...

  9. NEON在Android中的使用举例【转】

    转自:http://blog.csdn.net/fengbingchun/article/details/37766607 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.  打开Eclip ...

  10. FTPS加密上传

    公司要求ftp接口不能以明文方式传输,所以adc系统将增加ftps方式 但是在网找了很多方式都无法实现用了方法一 FtpWebRequest request = (FtpWebRequest)WebR ...