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 ...
随机推荐
- exception Access restriction: The type 'BASE64Encoder' is not API
Created by Marydon on 1.情景展示 在eclipse中切换jdk版本后,报错信息为:exception Access restriction: The type 'BASE6 ...
- XML 文档结构必须从头至尾包含在同一个实体内
XML 文档结构必须从头至尾包含在同一个实体内 CreateTime--2018年4月2日16:40:58 Author:Marydon 问题还原: <![CDATA[ <?xml v ...
- centos7 卸载 gitlab
标黑的就是关键命令,先停止gitlab服务,然后rpm -e卸载,然后查看剩余gitlab进程,然后杀死主进程,然后删除所有相关目录 1 [liuyx@MiWiFi-R3L-srv ~]$ sudo ...
- 掀开图片显示介绍的css效果
概述 主要运用到CSS3的3D transform等变换 详细 代码下载:http://www.demodashi.com/demo/10575.html 一.概述 1.主要运用到CSS3的3D tr ...
- ScriptManager.RegisterAsyncPostBackControl 方法
来源:VS2012帮助文档 用途: 将控件注册为异步回发的触发器 语法: public void RegisterAsyncPostBackControl( Control control ) 参数 ...
- caffe与MATLAB连接踩的坑
刚来公司用的服务器,分配给自己账号,安装了caffe,配好了Makefile.config中的MATLAB dir. 之后问题来了 解决方法: 在Makefile里面,大约第410行那一句话CXXFL ...
- nyoj-----前缀式计算
前缀式计算 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 先说明一下什么是中缀式: 如2+(3+4)*5这种我们最常见的式子就是中缀式. 而把中缀 ...
- HDUOJ----(1030)Delta-wave
Delta-wave Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- PAT 1086 Tree Traversals Again
PAT 1086 Tree Traversals Again 题目: An inorder binary tree traversal can be implemented in a non-recu ...
- Python2 字典 cmp() 函数
描述 Python 字典的 cmp() 函数用于比较两个字典元素,如果 dict1 < dict2 返回 -1, 如果 dict1 == dict2 返回 0, 如果 dict1 > di ...