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 ...
随机推荐
- oracle 批量更新之update case when then
oracle 批量更新之update case when then CreationTime--2018年8月7日15点51分 Author:Marydon 1.情景描述 根据表中同一字段不同情况 ...
- Hive之简单查询不启用MapReduce
假设你想查询某个表的某一列.Hive默认是会启用MapReduce Job来完毕这个任务,例如以下: 01 hive> SELECT id, money FROM m limit 10; 02 ...
- extends android.view.ViewGroup两种实现
/* private int measureHeight(int heightMeasureSpec) { int count = getChildCount(); ...
- 更改虚拟内存(使用于win7、win8系统)
在使用电脑的过程中你肯定有这样的抱怨吧!电脑为什么越来越慢?C盘为什么越来越小?我们都非常清楚:C盘剩余空间量的大小,很大程度上决定着我们在使用电脑的过程中程序运行的速度.随着电脑软件越装越多,尽管我 ...
- 在oracle数据库表中没有添加rowid字段为什么会出现?
rowid 是 oracle 数据库表中的伪列, rowid 首先是一种数据类型,它唯一标识一条记录物理位置, 基于64位编码的18个字符显示.因为 rowid 是伪列, 所以并未真的存储在表中,但可 ...
- HDUOJ----(1031)Design T-Shirt
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- 【LeetCode】130. Surrounded Regions (2 solutions)
Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A ...
- PHP5.4新特性
PHP5.4 此次更新的关键新特性,包括:新增traits,更精简的Array数组语法,供测试使用的内建webserver,可以闭包使用的$this指针,实例化类成员访问, PHP 5.4.0 性能大 ...
- js LINQ教程
在说LINQ之前必须先说说几个重要的C#语言特性 一:与LINQ有关的语言特性 1.隐式类型 (1)源起 在隐式类型出现之前, 我们在声明一个变量的时候, 总是要为一个变量指定他的类型 甚至在fore ...
- oc 代码块的使用
#import <UIKit/UIKit.h> #import "AppDelegate.h" int (^max)(int,int);//定义代码块,类似c的函数指针 ...