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 ...
随机推荐
- Eclipse 如何导入MyEclipse的项目
Eclipse 如何导入MyEclipse的项目 CreateTime--2018年3月8日09:53:55 Author:Marydon 1.Eclipse导入MyEclipse的项目方法,跟导 ...
- 【Spark】RDD操作具体解释3——键值型Transformation算子
Transformation处理的数据为Key-Value形式的算子大致能够分为:输入分区与输出分区一对一.聚集.连接操作. 输入分区与输出分区一对一 mapValues mapValues:针对(K ...
- java线程具体解释
线程与进程的差别 (1)程序是一段静态的代码,进程是程序的一次动态执行过程.它是操作系统资源调度的基本单位.线程是比进程更小的执行单位.一个进程在其执行过程中,能够产生多个线程.所以又称线程为&quo ...
- openfire + spark 展示组织机构(客户端)
在spark 加一个插件用于展示组织机构, 参考了好多人的代码 插件主类增加一个 TAB用于展示机构树 package com.salesoa.orgtree; import java.net.URL ...
- PHP原生:分享一个轻量级的缓存类=>cache.php
适用:原生PHP cache.php tips:代码最后有适用Demo哦. <?php /* * 缓存类 cache */ define("cacheRoot"," ...
- iOS archive(归档)
归档是一种很常用的文件储存方法,几乎任何类型的对象都能够被归档储存(实际上是一种文件保存的形式),浏览网上的一些资料后,并结合自己的一些经验,总结成此文. 一.使用archiveRootObject进 ...
- 个人网站不输入www.直接domain.com访问不了,输入www.domain.com能访问
网站访问跳转到/cgi-sys/defaultwebpage.cgi页面原因之一ip地址不对解决后,www.domain.com是可以访问了.但是直接domain.com去不能? 我记得刚开始 ...
- Android——点击对话框上按钮不关闭对话框
有时候我没可能需要在点击按钮进行一些检测,但是并不想关闭次对话框(系统默认点击任何一个按钮则关闭对话框),处理方法如下:在点击事件下添加如下代码: try { Field field = dialog ...
- CentOS 6.7下配置 yum 安装 Nginx。
第一步,在/etc/yum.repos.d/目录下创建一个源配置文件nginx.repo: cd /etc/yum.repos.d/ vim nginx.repo 填写如下内容: [nginx]nam ...
- Python 字典 copy()方法
描述 Python 字典 copy() 方法返回一个字典的浅拷贝(父不变,子变). 语法 copy() 方法语法: D.copy() 参数 无. 返回值 返回一个字典的浅拷贝(父不变,子变). 实例 ...