Home Page Web Parts Auto-Configuration

PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的第三部,是用PowerShell配置SharePoint页面的web parts' settings以及生成相关的SharePoint数据以支持web part的正常工作。

Prerequisite:

本次内容为*** Home Page自动部署三步中最后一步,将完成*** HomePage主Jira上“HomePage各web part配置文档”中第九步之后的所有关于配置web part的相关内容。

General:

自动配置My Documents web part settings

自动配置Site Management web part settings

自动配置My Tasks web part settings

自动创建Scanned Documents所需要的Task List并命名为“***Tasks”

自动配置Administration web part settings

自动配置Quick Links web part settings

自动创建Quick Links web part所关联的Links List

自动生成Title,Description,Order,RedirectURL,RedirectMethod五个column

自动添加五种column到All Items view下

*由于Workflow属用户第三方Service,所以本次配置中并不包含Workflow相关。

Method:Right click and run it with PowerShell.

#This third solution should be used after the second solution which keeps a name of "HomePage Auto-Create"

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Write-Host "Initializing..."

$Time = Get-Date

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

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

$HomePageURL = "https://teamsite.migration.net/sites/" + $Today + ".HomePage/Pages/***HomePage.aspx"

$HomePageSiteCollection = Get-SPSite -Identity $siteURL

$HomePageWeb = $HomePageSiteCollection.rootweb

$HomePagePubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($HomePageWeb)

$HomePage = $HomePagePubWeb.GetPublishingPage($HomePageURL)

Write-Host "Begin to configure the HomePage web parts..."

$HomePage.CheckOut()

$HomePageWeb.AllowUnsafeUpdates = $true

$limitedWebPartManager = $HomePage.ListItem.File.GetLimitedWebPartManager([System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#Modify the configuration information of the My Documents web part.

Write-Host "Begin to configure the My Documents web part..."

$MyDocumentsWebPart = $limitedWebPartManager.WebParts|where{$_.DisplayTitle -like '*My Documents*'}

$MyDocumentsWebPart.SearchServiceName = "SharePoint_Search_Proxy_***"

$MyDocumentsWebPart.DataBaseName = "DocAve6_ReportDB_***"

$MyDocumentsWebPart.ServerName = "***DB"

$MyDocumentsWebPart.Description = "Document Management Web Part"

$MyDocumentsWebPart.ChromeType = "TitleOnly"

#Modify the configuration information of the Site Management web part.

Write-Host "Begin to configure the Site Management web part..."

$SiteManagementWebPart = $limitedWebPartManager.WebParts|where{$_.DisplayTitle -like '*Site Management*'}

$SiteManagementWebPart.DataBaseName = "DocAve6_ReportDB_***"

$SiteManagementWebPart.ServerName = "***DB"

$SiteManagementWebPart.SearchServiceName = "SharePoint_Search_Proxy_***"

$SiteManagementWebPart.ChromeType = "TitleOnly"

#Modify the configuration information of the My Tasks web part.

Write-Host "Begin to configure the My Tasks web part..."

$MyTasksWebPart = $limitedWebPartManager.WebParts|where{$_.DisplayTitle -like '*Task*'}

$MyTasksWebPart.ChromeType = "TitleOnly"

#Create the task list

#$HomePageWeb.ListTemplates|where{$_.name -like 'tasks'}

Write-Host "Begin to create the tasks list with the name of '***Tasks' to work for the scanned documents module..."

$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::Tasks

$ListCollection = $HomePageWeb.Lists

$ListCollection.Add("***Tasks","Work for *** HomePage My Tasks web part.",$listTemplate)

$ListCollection.Update()

$TasksList = $HomePageWeb.Lists|where{$_.title -like '***Tasks'}

$TasksList.OnQuickLaunch = "True"

$TasksList.Update()

#Scanned Documents settings

Write-Host "Begin to configure the Scanned Documents module..."

$MyTasksWebPart.ScanDocument_Title = "Scanned Documents"

$MyTasksWebPart.ScanDocument_LinkScript = "#"

#Service Catalogue settings

Write-Host "Begin to configure the Service Catalogue module..."

$MyTasksWebPart.ServiceCatalogue_Title = "Service Catalogue"

$MyTasksWebPart.ServiceCatalogue_Link = "#"

#Workflow settings

Write-Host "Begin to configure the Workflow module(Only basic)..."

$MyTasksWebPart.Workflow_Title = "Workflow"

$MyTasksWebPart.Workflow_Link = "#"

#SS settings

Write-Host "Begin to configure the Target for the scanned documents module..."

$MyTasksWebPart.SS_TargetWebUrl = $siteURL

$MyTasksWebPart.SS_TargetListName = "***Tasks"

$MyTasksWebPart.SS_RequestRootUrl_SC = "https://***damanager.migration.net:15999"

#Create the Links list

#$HomePageWeb.ListTemplates|where{$_.name -like 'tasks'}

Write-Host "Begin to create the Links list to work for the Quick Links web part..."

$listTemplate = $HomePageWeb.ListTemplates|where{$_.name -like 'custom list'}

$ListCollection = $HomePageWeb.Lists

$ListCollection.Add("Links","Work for *** HomePage Quick Links web part.",$listTemplate)

$ListCollection.Update()

$LinksList = $HomePageWeb.Lists|where{$_.title -like 'Links'}

Write-Host "Add the quick launch for Links list..."

$LinksList.OnQuickLaunch = "True"

#Create column fields to the list

Write-Host "Create the fields..."

$TextFieldType = [Microsoft.SharePoint.SPFieldType]::Text

$NumberFieldType = [Microsoft.SharePoint.SPFieldType]::Number

$ChoiceFieldType = [Microsoft.SharePoint.SPFieldType]::Choice

#Add choices under the choice field

$choices = New-Object System.Collections.Specialized.StringCollection

$choices.Add("_blank")

$choices.Add("_self")

#Add the fields to the Links List

Write-Host "Add the fields to the Links list..."

$DescriptionField = $LinksList.Fields.Add("Description",$TextFieldType,$false)

$OrderField = $LinksList.Fields.Add("Order",$NumberFieldType,$false)

$RedirectURLField = $LinksList.Fields.Add("RedirectURL",$TextFieldType,$false)

$RedirectMethodField = $LinksList.Fields.Add("RedirectMethod",$ChoiceFieldType,$false,$false,$choices)

#Add the fields to the Links List's default view

Write-Host "Add the fields to the All Items view..."

$LinksDefaultView = $LinksList.views|where{$_.views -like 'All Items'}

$LinksDefaultView.ViewFields.Add($DescriptionField)

$LinksDefaultView.ViewFields.Add($OrderField)

$LinksDefaultView.ViewFields.Add($RedirectURLField)

$LinksDefaultView.ViewFields.Add($RedirectMethodField)

$LinksDefaultView.Update()

#Add the "Try to find a site?" item to the Links list

Write-Host "Add the 'Try to find a site?' item to the Links list..."

$DefaultListItem = $LinksList.AddItem()

$DefaultListItem["Title"] = "Try to find a site?"

$DefaultListItem["Description"] = "FNA(Financial News Alert)"

$DefaultListItem["Order"] = 1

$DefaultListItem["RedirectURL"] = "https://***damanager.migration.net:15999/SiteCollectionDirectoryReport/ViewPublishReports?SPHostUrl=https://teamsite.migration.net/sites/ForHomePageTesting/"

$DefaultListItem["RedirectMethod"] = "_self"

$DefaultListItem.Update()

$LinksList.Update()

#Modify the configuration information of the Quick Links web part.

Write-Host "Begin to configure the Quick Links web part..."

$QuickLinksWebPart = $limitedWebPartManager.WebParts|where{$_.DisplayTitle -like '*Quick Links*'}

$QuickLinksWebPart.ChromeType = "TitleOnly"

#Modify the configuration information of the Administration web part.

Write-Host "Begin to configure the Administration web part..."

$AdministrationWebPart = $limitedWebPartManager.WebParts|where{$_.DisplayTitle -like '*Administration*'}

$AdministrationWebPart.ChromeType = "None"

$AdministrationWebPart.DesktopActivityLogURL = "https://teamsite.migration.net/sites/activitylog test"

$AdministrationWebPart.TaxonomyManagementURL = "https://teamsite.migration.net/sites/Taxonomy%20Case/_layouts/15/***TaxonomyManagement/TaxonomyManagement.aspx"

$AdministrationWebPart.CollaborationDashboardURL = "https://teamsite.migration.net/sites/ForHomePageTesting/SitePages/collabration.aspx"

$AdministrationWebPart.ServiceCatalogueAdministrationURL = "https://***damanager.migration.net:15999"

$AdministrationWebPart.DocAveURL = "https://***damanager.migration.net:14999"

#$AdministrationWebPart.WorkflowWSUrl

#$AdministrationWebPart.WorkflowWSMethod

#$AdministrationWebPart.WorkflowJUMPUrl

#Save the changes to the web parts

Write-Host "Begin to save all the configurations..."

$limitedWebPartManager.SaveChanges($MyDocumentsWebPart)

$limitedWebPartManager.SaveChanges($SiteManagementWebPart)

$limitedWebPartManager.SaveChanges($MyTasksWebPart)

$limitedWebPartManager.SaveChanges($QuickLinksWebPart)

$limitedWebPartManager.SaveChanges($AdministrationWebPart)

$HomePage.Update()

$HomePage.CheckIn("")

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

$HomePageWeb.Dispose()

Write-Host "The HomePage has been configured successfully!"

Read-Host "Press any key to continue"

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

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

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

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

    *** HomePage Auto-Create Solution Monday, January 12, 2015   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. global语句(python学习手册422页)

    # -*- coding: cp936 -*- #python 27 #xiaodeng #global语句(python学习手册422页) #实际上就是一个名为__builtin__的模块,但是必须 ...

  2. 解决a标签IE下点击后出现轮廓框

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. Java实现可视化迷宫

    代码地址如下:http://www.demodashi.com/demo/14547.html 需求 使用深度优先算法求解迷宫路径,使用Java实现求解过程的可视化,可单步运行,形象直观. 演示效果 ...

  4. TP3.2校验微信公众号||小程序 服务器地址

    1.在TP3.2里面,写一个控制器,用来校验微信公众号||小程序的服务器地址 <?php namespace Home\Controller; use Think\Controller; hea ...

  5. struts2的DevMode(开发模式)模式

    本文转自:http://blog.csdn.net/q1054261752/article/details/48687119 在实际应用开发或者是产品部署的时候,对应着两种模式: ① 开发模式(dev ...

  6. [iOS]过渡动画之高级模仿 airbnb

    注意:我为过渡动画写了两篇文章:第一篇:[iOS]过渡动画之简单模仿系统,主要分析系统简单的动画实现原理,以及讲解坐标系.绝对坐标系.相对坐标系,坐标系转换等知识,为第二篇储备理论基础.最后实现 Ma ...

  7. Python学习笔记016——面向对象

    面向对象是指用类来描述一个对象(实例),用类来建立实例与实例的关联关系 对象 : object     实例 : instance 1 类 1.1 什么是类 类是用来描述对象的工具,用类可以创建一个或 ...

  8. ASP.NET MVC ajax处理 AjaxResult

    1.统一ASPNET MVC 对ajax请求响应格式定义,方便前端统一处理ajax结果. 1)定义程序返回结果数据格式 /// <summary> /// 执行结果 /// </su ...

  9. 关于c语言内存分配,malloc,free,和段错误,内存泄露

    1.   C语言的函数malloc和free (1) 函数malloc和free在头文件<stdlib.h>中的原型及参数        void * malloc(size_t size ...

  10. MongoDB索引类型

    与关系型数据库一样,合理的使用索引可以大幅提高MongoDB的查询效率,本文介绍基础索引.复合索引.文档索引等几种常用索引的使用. 1. 基础索引与复合索引 1.1 基础索引 创建索引时,可以是一个集 ...