转载请注明出自天外归云的博客园: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. [原创]java WEB学习笔记54:Struts2学习之路--- 编写Struts2 的第一个程序,HelloWord,简述 package ,action,result

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  2. vmware ubuntu server 联网

    查看本地ip 直接输入命令 ifConfig 只有 lo ,而没有eth0和eth1: 输入命令ifconfig -a,lo.eth0皆存在: 但是eth0 完全没有ip地址等,可以通过修改 /etc ...

  3. Android Preview显示

    Android Studio的功能包含preview窗口, 可以查看布局(layout)的样式; 位置: app->src->main->res(资源)->layout(布局) ...

  4. mldn android

    ed2k://|file|%E9%AD%94%E4%B9%90%E7%A7%91%E6%8A%80_Android%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98%E7%BB% ...

  5. php扩展的基本安装

    phpize ./config --with-php-config=.. make&make install php.ini

  6. 关于header跳转之后的乱码问题

    关于header跳转之后的乱码问题 http://www.360doc.com/content/11/0603/19/7052474_121495648.shtml 问题:不同网站的跳转出现乱码,不同 ...

  7. archlinux 网络配置

    https://wiki.archlinux.org/index.php/Network_configuration_%28%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%2 ...

  8. 查找(AVL平衡二叉树)

    [1]为什么需要平衡二叉树? 矛盾是推进事物向前发展的源动力. 那么平衡二叉树是从哪里来?肯定是有矛盾存在的.请看程来师的分析: [2]什么是平衡二叉树? 平衡二叉树的基本认识: [3]平衡二叉树的构 ...

  9. 忘记windows的登陆密码

    http://user.qzone.qq.com/372806800/blog/1342261571

  10. Java字符串转换

    public class StringConvertToInt{ public static void main(String[] args) { String a ="12a34bW()5 ...