SharePoint自动化系列——通过PowerShell创建SharePoint Web

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

转载请注明出自天外归云的博客园: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=0;$i -le $webApps.count-1;$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 0)
    {
        #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=0;$i -le $siteCollections.count-1;$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

相关文章
|
Web App开发 IDE JavaScript
Selenium IDE:Web自动化测试的得力助手
Selenium IDE:Web自动化测试的利器。作为开源工具,Selenium IDE支持录制与回放用户操作,适用于Chrome、Firefox等多浏览器,简化了测试流程,提升了效率,降低了自动化测试的门槛。它还支持导出多种编程语言的脚本,便于测试集成与复用。
497 31
Selenium IDE:Web自动化测试的得力助手
|
Web App开发 IDE 测试技术
Selenium:强大的 Web 自动化测试工具
Selenium 是一款强大的 Web 自动化测试工具,包括 Selenium IDE、WebDriver 和 Grid 三大组件,支持多种编程语言和跨平台操作。它能有效提高测试效率,解决跨浏览器兼容性问题,进行性能测试和数据驱动测试,尽管存在学习曲线较陡、不稳定等缺点,但其优势明显,是自动化测试领域的首选工具。
1282 17
Selenium:强大的 Web 自动化测试工具
|
Kubernetes Java 持续交付
小团队 CI/CD 实践:无需运维,Java Web应用的自动化部署
本文介绍如何使用GitHub Actions和阿里云Kubernetes(ACK)实现Java Web应用的自动化部署。通过CI/CD流程,开发人员无需手动处理复杂的运维任务,从而提高效率并减少错误。文中详细讲解了Docker与Kubernetes的概念,并演示了从创建Kubernetes集群、配置容器镜像服务到设置GitHub仓库Secrets及编写GitHub Actions工作流的具体步骤。最终实现了代码提交后自动构建、推送镜像并部署到Kubernetes集群的功能。整个过程不仅简化了部署流程,还确保了应用在不同环境中的稳定运行。
1097 9
|
监控 网络协议 安全
员工网络监控软件:PowerShell 在网络监控自动化中的应用
在数字化办公环境中,企业对员工网络活动的监控需求日益增长。PowerShell 作为一种强大的脚本语言,能够有效实现员工网络监控自动化。本文介绍了如何使用 PowerShell 获取网络连接信息、监控特定网址的访问情况,并生成自动化报告,帮助企业高效管理员工网络活动,确保网络安全和合规性。
435 0
|
Web App开发 测试技术 数据安全/隐私保护
自动化测试的魔法:使用Python进行Web应用测试
【10月更文挑战第32天】本文将带你走进自动化测试的世界,通过Python和Selenium库的力量,展示如何轻松对Web应用进行自动化测试。我们将一起探索编写简单而强大的测试脚本的秘诀,并理解如何利用这些脚本来确保我们的软件质量。无论你是测试新手还是希望提升自动化测试技能的开发者,这篇文章都将为你打开一扇门,让你看到自动化测试不仅可行,而且充满乐趣。
|
Web App开发 设计模式 JavaScript
自动化测试之美:如何利用Selenium实现Web应用的高效测试
【10月更文挑战第29天】在软件开发的世界中,测试是确保产品质量的关键步骤。本文将带你了解如何使用Selenium这一强大的自动化测试工具,提高Web应用测试的效率和准确性。通过实际案例,我们将探索Selenium的核心功能及其在现代软件开发中的应用,旨在帮助读者掌握自动化测试的精髓,从而提升软件测试工作的整体效能。
318 0
|
监控 关系型数据库 MySQL
PowerShell 脚本编写 :自动化Windows 开发工作流程
PowerShell 脚本编写 :自动化Windows 开发工作流程
781 0
|
Web App开发 Java 测试技术
一、自动化:web自动化。Selenium 入门指南:从安装到实践
一、自动化:web自动化。Selenium 入门指南:从安装到实践
322 0
|
7月前
|
数据采集 运维 监控
爬虫与自动化技术深度解析:从数据采集到智能运维的完整实战指南
本文系统解析爬虫与自动化核心技术,涵盖HTTP请求、数据解析、分布式架构及反爬策略,结合Scrapy、Selenium等框架实战,助力构建高效、稳定、合规的数据采集系统。
1190 62
爬虫与自动化技术深度解析:从数据采集到智能运维的完整实战指南

热门文章

最新文章