转载请注明出自天外归云的博客园: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的更多相关文章

  1. SharePoint自动化系列——通过PowerShell创建SharePoint Site Collection

    通过PowerShell创建SharePoint Site Collection,代码如下: Add-PSSnapin microsoft.sharepoint.powershell function ...

  2. SharePoint自动化系列——通过PowerShell创建SharePoint Lists

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  3. SharePoint自动化系列——通过PowerShell创建SharePoint List Items

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 代码如下(保存到本地ps1文件中,右键run with PowerShell即可): Add-PS ...

  4. SharePoint自动化系列——通过PowerShell在SharePoint中批量做数据

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell是基于.NET的一门脚本语言,对于SharePoint一些日常操作支持的很好. ...

  5. SharePoint自动化系列——Upload files to SharePoint library using PowerShell.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 日常的SharePoint站点测试中,我们经常要做各种各样的数据,今天又写了几个脚本,发现自己写的 ...

  6. 使用PowerShell 创建SharePoint 站点

    使用PowerShell 创建SharePoint 站点         在SharePoint开发中,你应该学会使用PowerShell管理SharePoint网站.SharePoint Manag ...

  7. SharePoint自动化系列——Site/Web/List级别的导航菜单

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 需求:在不同的测试用例中,对脚本中不确定的因素需要和用户交互来确定,比如选择哪个site,选择哪个 ...

  8. SharePoint自动化系列——创建MMS terms

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ PowerShell脚本实现MMS group.termSet.terms的自动化创建: Add- ...

  9. SharePoint自动化系列——通过Coded UI录制脚本自动化创建SharePoint Designer Reusable Workflow

    Coded UI非常好,我开始还在想,怎么样能让一个通过SharePoint Designer创建的Workflow publish三百五十次?想不到一个好的方法,也不知道SharePoint Des ...

随机推荐

  1. Druid register mbean error

    key: [com.alibaba.druid.stat.DruidDataSourceStatManager.addDataSource(DruidDataSourceStatManager.jav ...

  2. java上传excel文件及解析

      java上传excel文件及解析 CreateTime--2018年3月5日16:25:14 Author:Marydon 一.准备工作 1.1 文件上传插件:swfupload: 1.2 文件上 ...

  3. jsp&html页面知识点集锦

      CreateTime--2016年12月16日16:08:03Author:Marydonjsp&html页面知识点集锦1.标签的class属性 标签同时拥有多个class时,要写在同一个 ...

  4. grid++ 开发教程

      grid++ 开发教程 CreateTime--2018年4月24日18:43:23 Author:Marydon 1.插入报表头.明细网格.报表尾 右键-->插入-->报表节--&g ...

  5. Web应用中的普通java程序获取资源文件

  6. 微信小程序信息展示

    概述 使用第三方在线API模拟数据,进行微信小程序开发.不会后端开发也可以体验微信小程序. 详细 代码下载:http://www.demodashi.com/demo/10719.html 一.准备工 ...

  7. 不止是动态化:Weex项目和阿里无线技术开源方向

    这是开发者正在书写的峥嵘岁月.受益开源,回馈社区.阿里巴巴集团已经开源115个项目,并正式加入FSF基金会,Apache基金会,linux 基金会和Xen的顾问团队,并在云栖大会北京峰会宣布AliSQ ...

  8. Web Service基础——规范及三要素

    1. Java中的Web Service规范 Java 中共有三种WebService 规范,分别是JAX-WS(JAX-RPC).JAX-RS.JAXM&SAAJ(废弃). 1.1 JAX- ...

  9. 深入PHP内核之opcode handler

    1.opcode结构 在Zend/zend_compile.h文件下 struct _zend_op { opcode_handler_t handler; znode_op op1; znode_o ...

  10. Nginx配置error_page 404错误页面

    问题由来 昨天一网友在segmentfault.com上提问,无法做404重定向 打开对方的网站随便输入一个错误的地址发现给出了404代码,但是页面完全空白,并没有显示404页面的设定内容 当时就明白 ...