SharePoint自动化系列——通过PowerShell创建SharePoint List Items
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
代码如下(保存到本地ps1文件中,右键run with PowerShell即可):
Add-PSSnapin microsoft.sharepoint.powershell
function CreateSPListItems()
{
$sites = Get-SPSite
if($sites.count -eq )
{
Write-Warning "There is no site available."
CreateSPListItems
}
else
{
Write-Host "Choose the site:" -ForegroundColor Yellow
for($i=;$i -lt $sites.count;$i++)
{
$tip = "["+$i+"]."+$sites[$i].url
Write-Host $tip
}
$choice = Read-Host "Enter the number before"
$tip = "You chose "+$choice+". "+"The site you chose is '"+$sites[[int]$choice].url+"'"
Write-Host $tip -ForegroundColor Green
Write-Host "Choose the web:" -ForegroundColor Yellow
$webs = $sites[[int]$choice].AllWebs
for($i=;$i -lt $webs.count;$i++)
{
$tip = "["+$i+"]."+$webs[$i].url
Write-Host $tip
}
$choice = Read-Host "Enter the number before"
$tip = "You chose "+$choice+". "+"The web you chose is '"+$webs[[int]$choice].url+"'"
Write-Host $tip -ForegroundColor Green
$lists = $webs[[int]$choice].lists
if($lists.count -eq )
{
Write-Warning "There is no list available."
CreateSPListItems
}
else
{
Write-Host "Choose the list:" -ForegroundColor Yellow
for($i=;$i -lt $lists.count;$i++)
{
$tip = "["+$i+"]."+$lists[$i].title
Write-Host $tip
}
$choice = Read-Host "Enter the number before"
$tip = "You chose "+$choice+". "+"The web you chose is '"+$webs[[int]$choice].url+"'"
$list = $lists[[int]$choice]
$tip = "The list you chose is '" + $list.title +"'"
Write-Host $tip -ForegroundColor Green
$amount = Read-Host "How many items do you want to create"
$titleEp = Read-Host "Give an example of the item title, such as 'tylan'"
for($i=;$i -le $amount;$i++){
$random = Get-Random
$sign = $date.month+$date.day+$date.hour+$date.minute+$date.second+$random
$newItem = $List.Items.Add()
$newItem["Title"] = $sign.ToString() + $titleEp + "TestData"
$newItem.Update()
}
$tip = "Items have been created successfully under the list '"+$list.title+"'."
Write-Host $tip -ForegroundColor Green
$choice = Read-Host "Press 'c' to continue"
if($choice -eq 'c')
{
CreateSPListItems
}
}
}
}
CreateSPListItems
运行界面:
SharePoint自动化系列——通过PowerShell创建SharePoint List Items的更多相关文章
- SharePoint自动化系列——通过PowerShell创建SharePoint Site Collection
通过PowerShell创建SharePoint Site Collection,代码如下: Add-PSSnapin microsoft.sharepoint.powershell function ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Web
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——通过PowerShell创建SharePoint Lists
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...
- SharePoint自动化系列——通过PowerShell在SharePoint中批量做数据
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...
- SharePoint自动化系列——Upload files to SharePoint library using PowerShell.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 日常的SharePoint站点测试中,我们经常要做各种各样的数据,今天又写了几个脚本,发现自己写的 ...
- 使用PowerShell 创建SharePoint 站点
使用PowerShell 创建SharePoint 站点 在SharePoint开发中,你应该学会使用PowerShell管理SharePoint网站.SharePoint Manag ...
- SharePoint自动化系列——Site/Web/List级别的导航菜单
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...
- SharePoint自动化系列——创建MMS terms
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...
- SharePoint自动化系列——Manage "Site Subscriptions" using PowerShell
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 你可以将普通的sites加入到你的site subscriptions中,前提是你需要有一个 Te ...
随机推荐
- python学习笔记之函数(方法)
def func(x): print 'x is', x x = 2 print 'Changed local x to', x x = 50 func(x) print 'x is still', ...
- java操作hdfs到数据库或者缓存
使用hadoop工具将数据分析出来以后,须要做入库处理或者存到缓存中.不然就没了意义 一下是使用javaAPI操作hdfs存入缓存的代码: <span style="font-fami ...
- TP3.2之WHERE组合条件处理
1.条件都是int类型: $User->where('type=1 AND status=1')->select(); 2.条件包含字符串类型: 使用3.1以上版本的话,使用字符串条件的时 ...
- archlinux使用sudo
Sudo是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等.这样不仅减少了root用户的登陆 和管理时间,同样也提高了安全性. Sudo不是对she ...
- 关于iOS 热更新(热修复)你必须知道的一种方法- JSPatch
本文为转载文章 . 版权归原文所有. 原文链接:iOS 5分钟集成热修复(JSPatch) 前言 在iOS中有很多种热修复方案,在这里我就不一一介绍了 这里有一篇介绍热修复的文章:iOS中的HotFi ...
- 【C++】int与string互转
int转string(注:itoa不是标准函数,OJ平台可能不接受) ; ]; string str; sprintf(temp, "%d", n); str = temp; or ...
- Linux命令-某个用户组下面的所有用户
groups 查看当前登录用户的组内成员 groups gliethttp 查看gliethttp用户所在的组,以及组内成员whoami 查看当前登录用户名 系统内有关组的信息放在/etc/group ...
- 《JAVA与模式》之桥接模式
桥接模式是一种结构型模式,它主要应对的是:由于实际的需要,某个类具有两个或两个以上的维度变化,如果只是用继承将无法实现这种需要,或者使得设计变得相当臃肿. 桥接模式的做法是把变化部分抽象出来,使变化部 ...
- 为什么百度首页的HTML源代码最后一行要多一行?浪费空间呀!
为什么百度首页的HTML源代码最后一行要多一行?浪费空间呀!
- 读"U盘小偷"有感
作者: sudami 嘿嘿,今天终于有时间学习自己喜欢的东西了,在kanxue里看到一篇关于U盘小偷的文章:http://bbs.pediy.com/showthread.php?p=381656#p ...