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 跨库查询表数据(不同的数据库间建立连接)
1.情景展示 当需要从A库去访问B库中的数据时,就需要将这两个库连接起来: 两个数据库如何实现互联互通,在oracle中,可以通过建立DBLINK实现. 2.解决方案 2018/12/05 第一步 ...
- exception PLS-00103: Encountered the symbol "(" when expecting one of the following:
exception PLS-00103: Encountered the symbol "(" when expecting one of the following: Cre ...
- 〖Linux〗使用Qt5.2.0开发Android的NDK应用程序
2013年12月11日,Qt发布了其新的Qt版本:Qt5.2.0: 利用这个新的版本,我们可以很轻松地制作出Android手机的NDK应用程序. 开发环境:Ubuntu13.10 x86_64 下载链 ...
- JDBC 实例--JDBC通过工具类DBUtil连接到数据库,让我们不再恐惧操作数据库
利用JDBC连接到数据库一般需要几个步骤: 1.装载驱动程序. 2.建立连接. 3.发送和执行SQL语句. 4.释放资源 首先建立一个数据库: 脚本如下: create database csdn; ...
- [SceneKit] 不会 Unity3D 的另一种选择
概述 SceneKit和SpriteKit的区别简单的来说就是二维和三维的区别 详细 代码下载:http://www.demodashi.com/demo/10664.html 上周一, 相信很多人和 ...
- skimage exposure模块解读
exposure模块包括: 直方图均衡化 gamma调整.sigmoid调整.log调整 判断图像是否对比度太低 exposure模块包括以下函数: histogram 统计颜色的直方图,基于nump ...
- 【LeetCode】88. Merge Sorted Array (2 solutions)
Merge Sorted Array Given two sorted integer arrays A and B, merge B into A as one sorted array. Note ...
- 解决修改计算机名后tfs连接不上的错误
1,用vs 自带的工具命令 tf workspaces 查看集合 2,执行命令: >tf workspaces /collection:https://aaaa.visualstudio.com ...
- ngx_lua学习笔记 -- capture + proxy 实现httpclient
题注 最近我在学习nginx的lua插件,发现结合nginx的异步io和lua的流程控制能力,还是有很丰富的想象空间的:几乎所有常见的http请求的处理逻辑都能搞定,诸如查查数据库,访问一下memca ...
- 正确关闭Redis
1.首先关闭单机版 我的单机版 是放在redis文件夹下面的 首先你要启动你的单机版redis 直接shutdown quit 退出去 ps aux|grep redis 查看运行的redis 关闭 ...