PowerShell实现基于SharePoint的网站HomePage Auto-Upgrade Solution
*** Solution Auto-Upgrade Solution
PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的第一部。主要是用PowerShell自动完成下载,解压缩一直到部署solution到SharePoint这一过程。
*** Solution Auto-Upgrade Script
Home Page Module Demo:
注:目前只支持HomePage Module,如果修改里面的可替换链接和字符串分析和路径分析的话将可以用在***所有部署Solution的模块,以下是文档内容。
User Guide:
1. Right click the script and run the script with PowerShell.
2. Input the package address and press the "Enter".
3. "Save as" the file under the path "C:\ HomePageSolution" (already been created automatically).
Result:
The solution will be upgraded automatically in the SharePoint Farm.
Script:
<#ftp function reference#>
Function Invoke-FtpLogin{
Param(
[parameter(Mandatory = $true)]
[string]$Site = "ftp://10.1.4.5/Monetary_Authority_of_Singapore/HomePageSolution/DailyBuild",
[string]$User = "Anonymous",
[string]$Pass = "",
[int]$Port=21,
[int]$TimeOut=3000,
[int]$ReadWriteTimeout=10000
)
Write-Host "Get FTP site dir listing..."
# Do directory listing
$FTPreq = [System.Net.FtpWebRequest]::Create($Site)
$FTPreq.Timeout = $TimeOut # msec (default is infinite)
$FTPreq.ReadWriteTimeout = $ReadWriteTimeout # msec (default is 300,000 - 5 mins)
$FTPreq.KeepAlive = $false # (default is enabled)
$FTPreq.Credentials = New-Object System.Net.NetworkCredential($User,$Pass)
$FTPreq.Method = [System.Net.WebRequestMethods+FTP]::ListDirectory
try
{
$FTPres = $FTPreq.GetResponse()
Write-Host "$User _ $Pass OK"
$success = $true
#Write-Host $FTPres.StatusCode -nonewline
#Write-Host $FTPres.StatusDescription
$FTPres.Close()
}
catch
{
Write-Host "FAILED: $_"
$success = $false
}
}
<#Unzip function reference#>
Function Unzip-File()
{
param([string]$ZipFile,[string]$TargetFolder)
#Make sure the file must be existed.
if(!(Test-Path $TargetFolder))
{
mkdir $TargetFolder
}
$shellApp = New-Object -ComObject Shell.Application
$files = $shellApp.NameSpace($ZipFile).Items()
$shellApp.NameSpace($TargetFolder).CopyHere($files)
}
<#HomePage Solution Auto-Update#>
#If not admin, open the ps1 with admin again.
$currentWi = [Security.Principal.WindowsIdentity]::GetCurrent()
$currentWp = [Security.Principal.WindowsPrincipal]$currentWi
if( -not $currentWp.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
$oldPid = $pid
$currentFile = $MyInvocation.MyCommand.Path
Start-Process "$psHome\powershell.exe" -ArgumentList $currentFile -verb runas
kill $oldPid
}
#Admin runs the script.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
New-Item c:\HomePageSolution -ItemType directory -ErrorAction SilentlyContinue
$ie = new-object -com InternetExplorer.Application
<#User input the newest package address#>
$packageURL = Read-Host "Please input the URL of the HomePage package"
$timeURL = $packageURL.substring(75,10)
$pieces = $timeURL -Split "-"
$cake = -join $pieces
$fileURL = "APPS***HomePageSolution_1.0.0.6_" + $cake +".zip"
$downloadURL = $packageURL + "/" + $fileURL
$ie.Navigate2($downloadURL)
$ie.Visible = $true
<#Wait until the download has been finished.#>
do
{
Start-Sleep -m 3000
}
until(Get-ChildItem c:\HomePageSolution|where{$_.name -like $fileURL})
<#Unzip the package after the download has been finished.#>
$UnzipPath = "c:\HomePageSolution\" + $fileURL
$goalPath = "c:\HomePageSolution\" + "APPS***HomePageSolution_1.0.0.6_" + $cake
Unzip-File -ZipFile $UnzipPath.tostring() -TargetFolder $goalPath.tostring()
$updatePath = $goalPath + "\" + "APPS***HomePage.wsp"
Update-SPSolution -Identity APPS***HomePage.wsp -LiteralPath $updatePath -GACDeployment
Read-Host "Press any key to quit"
PowerShell实现基于SharePoint的网站HomePage Auto-Upgrade Solution的更多相关文章
- PowerShell实现基于SharePoint的网站HomePage Auto-Configure Solution
Home Page Web Parts Auto-Configuration PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell写的一个自动化升级工具,此为三部自动化工具的 ...
- PowerShell实现基于SharePoint的网站HomePage Auto-Create Solution
*** HomePage Auto-Create Solution Monday, January 12, 2015 PS:该项目为公司项目,我还是给他的名字屏蔽掉吧,这是我用PowerShell ...
- 实现一个基于 SharePoint 2013 的 Timecard 应用(上)
在 SharePoint 2013 上面实现一个 Timecard 应用的想法来自一个真实的需求,而实现的方案在我脑海里面盘旋已经很久了,终于这几天准备安排点儿时间将它实现出来. “ We start ...
- 优化移动设备上SharePoint 2013网站
优化移动设备上SharePoint 2013网站 本文由SPFarmer翻译自Waldek Mastykarz的文章 移动市场在持续的增长.在不远的将来,使用移动设备浏览站点将会超过电脑.为了保证用户 ...
- SharePoint 开启网站匿名访问图文详解
SharePoint 开启网站匿名,需要先开启web application的匿名访问,然后开启site的匿名访问.特别的,site可以选择整个网站开启或者列表和库开启匿名,如果选择列表和库开启匿名, ...
- 基于jQuery的网站首页宽屏焦点图幻灯片
今天给大家分享一款基于jQuery的网站首页宽屏焦点图幻灯片.这款焦点图适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之窗.效果图如下: 在线预览 ...
- 基于jQuery商城网站全屏图片切换代码
基于jQuery商城网站全屏图片切换代码.这是一款商城网站全屏多张图片滑动切换代码.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="slid ...
- SharePoint 2013网站突然不能登录了。
SharePoint 2013网站突然不能登录了,访问的时候,总是报错: The list has not shared with you. 原因: 原来我不知道什么时候把web applicat ...
- 在PowerShell中操作SharePoint对象
1. 用PowerShell创建一个SharePoint内容对象创建一个自定义列表:$SPSite = New-Object Microsoft.SharePoint.SPSite("htt ...
随机推荐
- linux达人养成计划学习笔记(五)—— 关机和重启命令
一.shutdown 1.格式: shutdown [选项] 时间(now) 选项: -c: 取消前一个关机命令 -h: 关机 -r: 重启 2.程序放入后台执行: shutdown -r 时间 &a ...
- Charles 网络抓包工具
1.Charles 简介 Charles 是在 Mac.Linux 或 Windows 下常用的 http 协议网络包截取工具,在平常的测试与调式过程中,掌握此工具就基本可以不用其他抓包工具了.Cha ...
- Html中 <tr> 标签的隐藏与显示
TR标签的隐藏与显示:block(显示)和none(隐藏) <tr style="display:none"> <tr id="sample" ...
- @property与@synthesize的差别
上一篇文章我有讲到self.与_的差别,往往和这个问题相伴随的是我困惑的问题是"@property与@synthesize的差别" @property的使用方法 @interfac ...
- Groovy 学习手册(4)
6. 领域特定语言 Groovy 有许多特性,使它非常适合写DSL(领域特定语言).这些特性包活: 具有委托机制的闭包: 点号(.)和语句末尾的分号(;)是可选的: 运算符的重载(例如,加号,减号等) ...
- Android开发:setAlpha()方法和常用RGB颜色表----颜色, r g b分量数值(int), 16进制表示 一一对应
杂家前文Android颜色对照表只有颜色和十六进制,有时候需要设置r g b分量的int值,如paint.setARGB(255, 127, 255, 212);就需要自己计算下分量的各个值.这里提供 ...
- 常用代码之四:创建jason,jason转换为字符串,字符串转换回jason,c#反序列化jason字符串的几个代码片段
1.创建jason,并JSON.stringify()将之转换为字符串. 直接使用var customer={}, 然后直接customer.属性就可以直接赋值了. 也可以var customer = ...
- 用python做网页抓取与解析入门笔记[zz]
(from http://chentingpc.me/article/?id=961) 事情的起因是,我做survey的时候搜到了这两本书:Computational Social Network A ...
- cent os 6.5+ambari+HDP集群安装
1. 搭建一个测试集群,集群有4台机器,配置集群中每一台机器的/etc/hosts文件: [root@nn .ssh]# cat /etc/hosts 127.0.0.1 localhost loca ...
- 参数化查询 '(@ActualShipTime datetime' 需要参数 @AuthorizationNumber,但未提供该参数。
转自 http://www.cnblogs.com/cxd4321/archive/2012/08/09/2629716.html 在平时的C#项目开发中,当调用某个存储过程或函数的时候,我们可能经常 ...