*** HomePage Auto-Create Solution

Monday, January 12, 2015
 
PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的第二部。主要是用PowerShell去创建一个SharePoint页面,并且按照规定顺序对其自动进行配置。

Automation :

本次自动化代替操作完成的是HomePage配置文档中设置步骤的1到9步(属于做数据阶段),由于HomePage结合的模块众多,添加web parts到页面的过程需要调用Leo哥写的各种后台过程,光靠调用SharePoint API是无法完成的,所以第九步后半部分的“将webpart一一对应的加入WebPart Zone中”这一过程为手动添加过程。(属于测试阶段,检查咱们添加的后台过程是否正常运行,1. My Documents web part的title url是否自动添加到web part setting中;2. 保存并点击title,检查header能顺利实现跳转;2. 检查My Documents web part和Site Management web part的header是否包含特定的黑框样式。)

​整个HomePage部署自动化包含三个阶段,第一阶段(详见上一篇)和第二阶段都已经完成了,最后一个阶段就是配置web part和修改web part信息的过程我也会找时间尝试写成自动配置的脚本。(感谢大神超哥@Leo Jiang巨指点,虽然这次没试上web part的导出导入和API,不过下次写web part的配置过程时就可以派上用途啦。)

HomePage设置步骤:

  1. Add Solution APPS***HomePage.wsp to Farm
  2. Deploy solution到homepage所在web application
  3. 创建Site Collection,作为Home Page使用的Site Collection。
  4. 进入Site Setting页面,点击Site collection features,激活SharePoint Server Publishing Infrastructure,Custom Page Layout Feature
  5. 返回Site Setting页面,点击Manage Site features,激活SharePoint Server Publishing
  6. 返回Site Setting页面,点击Site collection features,激活Home Page Web Part Feature
  7. 设置Site的***ter page为Seattle
  8. 点击Site Contents,进入Pages Library,点击Ribbon上的New Documents,创建Article Page,Page Layout选择*** Home Page
  9. 创建好Home Page对应的publishing page

METHOD: Right click the tool and run it as administrator.

​Result: The *** Home Page will be created and open automatically.

Script Code:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$Time = Get-Date

$Today = $Time.year.toString() + "." + $Time.month.toString() + "." + $Time.day.toString()

$TodayIs = "Today is " + $Today.toString()

$TodayIs

$siteURL = "https://teamsite.migration.net/sites/" + $Today + ".HomePage"

Write-Host "Today's HomePage is creating..."

New-SPSite -URL $siteURL -OwnerAlias "soe\tuser2" -Language 1033 -CompatibilityLevel 15 -Template "STS#0"

$HomePageSiteCollection = Get-SPSite -Identity $siteURL

Write-Host "The HomePage site collection has been created successfully."

#Enable the site collection level publishing feature

Write-Host "Enabling the site collection level publishing feature..."

Enable-SPFeature -Id F6924D36-2FA8-4f0b-B16D-06B7250180FA -Url $siteURL

Write-Host "The site collection level publishing feature has been enabled."

#Enable the *** custom page layout feature

Write-Host "Enabling the *** custom page layout feature..."

Enable-SPFeature -Id AFBAA18A-CD2A-4866-AE01-EB1B35778687 -Url $siteURL

Write-Host "The *** custom page layout feature has been enabled."

#Enable the web level publishing feature

Write-Host "Enabling the web level publishing feature..."

Enable-SPFeature -Id 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb -Url $siteURL

Write-Host "The web level publishing feature has been enabled."

#Enable the HomePage web part feature

Write-Host "Enabling the HomePage feature..."

Enable-SPFeature -Id 8efd39bf-e322-41a6-80c8-a82c531f0fa1 -Url $siteURL

Write-Host "The HomePage feature has been enabled."

#Change the system ***ter page

Write-Host "Changing the system ***ter page into seattle..."

$HomePageSiteCollection.rootweb.***terUrl  = "/sites/" + $Today + ".HomePage/_catalogs/***terpage/seattle.***ter"

Write-Host "The system ***ter page has been changed."

#Change the site ***ter page

Write-Host "Changing the site ***ter page into seattle..."

$HomePageSiteCollection.rootweb.Custom***terUrl  = "/sites/" + $Today + ".HomePage/_catalogs/***terpage/seattle.***ter"

Write-Host "The site ***ter page has been changed."

#Save the change

Write-Host "Save the changes..."

$HomePageSiteCollection.rootweb.update()

Write-Host "The changes has been saved to the HomePage's site collection."

#Create the HomePage

Write-Host "Creating the HomePage automatically..."

$spWeb = $HomePageSiteCollection.rootweb

$pubWeb =[Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($spWeb)

$pageLayout = $pubWeb.GetAvailablePageLayouts()|where{$_.name -like '*DMSHome*'}

$HomePage = $pubWeb.AddPublishingPage("***HomePage.aspx",$pageLayout) #filename need end with .aspx extension

$HomePage.Update()

$HomePage.CheckIn("")

$HomePage.ListItem.File.Publish("")

$spWeb.Dispose()

Write-Host "The HomePage has been created successfully..."

$HomePageURL = $siteURL + "/Pages/***HomePage.aspx"

$shell = New-Object -ComObject Shell.Application

$shell.Open($HomePageURL)

Read-Host "Press any key to continue"​​

PowerShell实现基于SharePoint的网站HomePage Auto-Create Solution的更多相关文章

  1. PowerShell实现基于SharePoint的网站HomePage Auto-Upgrade Solution

    *** Solution Auto-Upgrade Solution Tuesday, January 06, 2015 PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell ...

  2. PowerShell实现基于SharePoint的网站HomePage Auto-Configure Solution

    Home Page Web Parts Auto-Configuration PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的 ...

  3. 实现一个基于 SharePoint 2013 的 Timecard 应用(上)

    在 SharePoint 2013 上面实现一个 Timecard 应用的想法来自一个真实的需求,而实现的方案在我脑海里面盘旋已经很久了,终于这几天准备安排点儿时间将它实现出来. “ We start ...

  4. 优化移动设备上SharePoint 2013网站

    优化移动设备上SharePoint 2013网站 本文由SPFarmer翻译自Waldek Mastykarz的文章 移动市场在持续的增长.在不远的将来,使用移动设备浏览站点将会超过电脑.为了保证用户 ...

  5. SharePoint 开启网站匿名访问图文详解

    SharePoint 开启网站匿名,需要先开启web application的匿名访问,然后开启site的匿名访问.特别的,site可以选择整个网站开启或者列表和库开启匿名,如果选择列表和库开启匿名, ...

  6. 基于jQuery的网站首页宽屏焦点图幻灯片

    今天给大家分享一款基于jQuery的网站首页宽屏焦点图幻灯片.这款焦点图适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗.效果图如下: 在线预览 ...

  7. 基于jQuery商城网站全屏图片切换代码

    基于jQuery商城网站全屏图片切换代码.这是一款商城网站全屏多张图片滑动切换代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div class="slid ...

  8. SharePoint 2013网站突然不能登录了。

    SharePoint 2013网站突然不能登录了,访问的时候,总是报错: The list has not shared with you.   原因: 原来我不知道什么时候把web applicat ...

  9. 在PowerShell中操作SharePoint对象

    1. 用PowerShell创建一个SharePoint内容对象创建一个自定义列表:$SPSite = New-Object Microsoft.SharePoint.SPSite("htt ...

随机推荐

  1. JavaScript实现碰撞检测(分离轴定理)

    概述 分离轴定理是一项用于检测碰撞的算法.其适用范围较广,涵盖检测圆与多边形,多边形与多边形的碰撞:缺点在于无法检测凹多边形的碰撞.本demo使用Js进行算法实现,HTML5 canvas进行渲染. ...

  2. JedisClient(示例)

    拷贝 import java.io.IOException; import java.util.HashSet; import java.util.Map; import java.util.Set; ...

  3. IDEA创建maven项目jar更新缓慢问题

    转自:http://www.cnblogs.com/ae6623/p/4416256.html 国内连接maven官方的仓库更新依赖库,网速一般很慢,收集一些国内快速的maven仓库镜像以备用. 最新 ...

  4. HDUOJ---Hamming Distance(4712)

    Hamming Distance Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  5. Linux下发布javaWeb项目,配置环境变量,tomcat,和安装mysql数据库

    如果不懂,可以联系微博本人:QQ:3111901846 (原创) 1.配置java中jdk 注意一切操作,都是在root这个目录下进行的,不要选择其他目录,不然会出现一些小问题的 第一步: 你需要一个 ...

  6. Android 手机震动功能实现

    1首先在AndroidManifest.xml中添加震动权限 <uses-permission android:name="android.permission.VIBRATE&quo ...

  7. Shell中重定向&lt;&lt;EOF注意事项

    作者:iamlaosong 我们常常在shell脚本程序中用<<EOF重定向输入.将我们输入的命令字符串作为一个运行程序的输入,这样,我们就不须要在那个程序环境中手工输入命令,以便自己主动 ...

  8. enumerate的简单使用

    l = [11,22,33,55,"ss","zz"] for i,v in enumerate(l): print(i,v) #打印结果: # 0 11 # ...

  9. 【转】容易被忽略CSS特性

    这里主要是为了留个备份,更好的排版请查看原文: http://www.cnblogs.com/dolphinX/p/3511300.html //以下为全文转载 CSS初学感觉很简单,但随着学习的深入 ...

  10. [Jobdu] 题目1214:丑数

    题目描述: 把只包含因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含因子7.习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 输入: 输 ...