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组中, ...
随机推荐
- Leetcode: Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...
- 微信开发---------jsapi_ticket拿不到的问题。
今天代码没动,出现的问题是分享朋友圈,朋友,分享到QQ,我设置的分享链接都失效了.找来找去也不知道什么原因,没办法就只有一个个打印参数并查看文档,先把jssdk页面上的debug设置为true(微信原 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...
- URAL 1002 Phone Numbers(KMP+最短路orDP)
In the present world you frequently meet a lot of call numbers and they are going to be longer and l ...
- android中获取打气筒的几种方式
1,简单说明,打气筒就是将我们的xml布局转换为我们的view对象,不扯远了,直接看代码 A:从context中获取 LayoutInflater inflater1 = LayoutInflater ...
- C#写好的类库dll怎么在别人调用的时候也能看到注释?
菜单 Project -> 'xxxx' Properties -> Build -> Output -> 勾上 XML Documentation file
- Android Handler练习
package com.example.myact12; import java.util.Random; import android.support.v7.app.ActionBarActivit ...
- 移动端下拉刷新,iScroll.js用法(转载)
本文转载自: iScroll.js 用法参考 (share)
- 浅谈JavaScript计时器
JavaScript计时器 1.什么是JavaScript计时器? 在JavaScript中,我们可以在设定的时间间隔之后来执行代码,而不是在函数被调用后立即执行. 2.计时器类型 一次性计时器:仅在 ...
- JSP-05- JSP总结
1 客户端请求新页面 <%@ page language="java" contentType="text/html; charset=UTF-8" ...