SharePoint自动化系列——通过PowerShell创建SharePoint Web
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
代码如下(保存到本地ps1文件中,右键run with PowerShell即可):
Add-PSSnapin Microsoft.SharePoint.PowerShell
function createSPWeb()
{
$webApps = Get-SPWebApplication
chooseWebAppAndSelectSite $webApps
}
function chooseWebAppAndSelectSite($webApps)
{
Write-Host "Web applications in the farm:" -ForegroundColor Yellow
for($i=;$i -le $webApps.count-;$i++)
{
$tip = "[" + $i.ToString() +"]" + $webApps[$i].name
Write-Host $tip -ForegroundColor Green
}
$choice = Read-Host "Select the web application, enter the number before"
$siteCollections = Get-SPSite -WebApplication $webApps[$choice].url
if($siteCollections.count -eq )
{
#Write warning tip here.
Write-Warning "There is no site collection under the web application, you need to make an alternative choice."
chooseWebAppAndSelectSite $webApps
}
else
{
Write-Host "Site collections under the web application:" -ForegroundColor Yellow
for($i=;$i -le $siteCollections.count-;$i++)
{
$tip = "[" + $i.ToString() + "]" +$siteCollections[$i].url
Write-Host $tip
}
$choice = Read-Host "Select the site collection, enter the number before"
$tip = "You want to create a new web(subsite) under the site collection " + $siteCollections[$i] + "? Enter 'y' to verify"
Write-Host $tip -ForegroundColor Cyan
$newChoice =Read-Host
if($newChoice -eq "y")
{
$name = Read-Host "Please enter the name of the web(subsite)"
$webUrl = $siteCollections[$choice].url + "/" + $name
write-host "The web(subsite) is creating, please wait for a moment..." -ForegroundColor DarkGreen
New-SPWeb -Url $webUrl -Name $name -Template "STS#0"
Write-Host "The web(subsite) has been created. The url is above." -ForegroundColor Green
}
}
}
createSPWeb
运行界面:
创建Site Collection的脚本,详见上一篇blog。
SharePoint自动化系列——通过PowerShell创建SharePoint Web的更多相关文章
- 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自动化系列——通过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自动化系列——通过Coded UI录制脚本自动化创建SharePoint Designer Reusable Workflow
Coded UI非常好,我开始还在想,怎么样能让一个通过SharePoint Designer创建的Workflow publish三百五十次?想不到一个好的方法,也不知道SharePoint Des ...
随机推荐
- const对象默觉得文件的局部变量
const 定义的对象为一个常量不能被改动. 这个想必大家都知道. 这里仅仅是介绍const对象默觉得文件的局部变量 当一个非const变量在一个c或cpp文件里为全局时,它在整个程序 ...
- mysql循环批量插入测试数据
http://blog.51cto.com/tianxingzhe/1676097 DROP PROCEDURE test_insert ; DELIMITER $$ CREATE PROCEDURE ...
- define() vs const 该如何选择?
使用 define(),除非考虑到可读性.类常量.或关注微优化 1.在 PHP 中是使用 define() 函数来定义常量,PHP 5.3.0 以后,PHP 中也能够使用 const 关键字来声明常量 ...
- CoreData数据库升级
如果IOS App 使用到CoreData,并且在上一个版本上有数据库更新(新增表.字段等操作),那在覆盖安装程序时就要进行CoreData数据库的迁移,具体操作如下: 1.选中你的mydata.xc ...
- TortoiseSVN 覆盖SVN仓库最新版本提交
情况背景: ibank.pdm文件最新版本有问题,版本号为5051. 我想在5050的版本上修改后提交,覆盖5051版本的修改,也就是经过我修改后的5050版本,覆盖5051版本的修改,提交成功并成为 ...
- bootstraptable toolbar
- Facade - 外观模式
1. 概述 外观模式,我们通过外观的包装,使应用程序只能看到外观对象,而不会看到具体的细节对象,这样无疑会降低应用程序的复杂度,并且提高了程序的可维护性.例子1:一个电源总开关可以控制四盏灯.一个风扇 ...
- 本地PC安装Centos 6.5 操作手册及遇到的问题
我采取的是使用U盘安装 一.准备工作 1.下载Centos6.5 ISO文件 我在官网上下的6.5版本CentOS-6.5-x86_64-bin-DVD1.iso, 由于CentOS-6.5-x86_ ...
- 解决windows server2012 评估版本过期,系统会自动关机
解决windows server2012 评估版本过期,系统在1小时后会自动关机. 重置方法:以管理员方式运行命令行,执行slmgr.vbs /rearm,可以使授权延长180天,但是仅能延长5次.
- java从Object类型转换成double类型
java从Object类型转换为double类型: Map<String,Object> map = new HashMap<String,Object>(); map.put ...