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 ...
随机推荐
- uva 699 The Falling Leaves(建二叉树同一时候求和)
本来看着挺难的.大概是由于我多瞟了一眼题解,瞬间认为简单多了.做题就得这样,多自己想想.如今是 多校联赛,然而我并不会做. .. .慢慢来,一直在努力. 分析: 题上说了做多不会超过80行.所以能够开 ...
- 捕获Chrome浏览器全屏退出事件
参考地址 document.addEventListener("fullscreenchange", function(e) { console.log("fullscr ...
- Fork me on GitHub
<a href="https://github.com/yadongliang"><img style="position: absolute; top ...
- Android开发学习之Activity的简介
1.Activity的概念介绍 Activity是Android组件中最基本也是最常用的一种组件,在一个Android应用中,一个Activity通常就是一个单独的屏幕.每一个Activity都被实现 ...
- Find and Grep
find 1.格式 Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [ ...
- 如何不让DataGridView自动生成列
如果不想让DataGridView自动生成与数据源对应的列, 只需要把属性AutoGenerateColumns设为false即可. 需要注意: 在界面设计的属性窗口中是看不到AutoGenerate ...
- RHCE7 -- IPv6
IPV6地址一个128位数字 如果在IPv6地址后面包括TCP和UDP网络端口,建议将IPv6放在方括号中,以便区分: [2001:db8:0:10::1]:80 IPv6的标准子网掩码是&q ...
- Python2 元组 cmp() 方法
描述 Python2 元组 cmp() 方法用于比较两个元组,如果 T1< T2返回 -1, 如果 T1== T2返回 0, 如果 T1> T2返回 1. 语法 cmp() 方法语法: c ...
- Js 常用函数【持续更新】
Js Math对象方法介绍:http://www.w3school.com.cn/jsref/jsref_obj_math.asp 1. 算数函数(Math) 1)Js小数取整 常用于:分页算法 js ...
- Struts如何获取客户端ip地址
在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的.但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实I ...