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 ...
随机推荐
- IT软件外包行业深入分析:现状、前途、趋势、待遇 什么是软件外包 外包公司是怎么工作的 软件外包公司的面试 软件外包公司需要什么样的人
目录: [0] - 为什么要对大学生谈软件外包? [1] - 什么是软件外包? [2] - 软件为什么要外包? [3] - 为什么要承接软件外包 [4] - 做软件外包有前途吗? [5] - 外包公司 ...
- fedora装机后要运行的脚本(原创)
脚本:sh.sh #!/bin/zsh #安装rpmfusion源 dnf config-manager --add-repo=http://repo.fdzh.org/FZUG/FZUG.repo ...
- linux 文件系统工作原理
转:<http://linuxperf.com/?p=153> 一.概述 文件系统要解决的一个关键问题是怎样防止掉电或系统崩溃造成数据损坏,在此类意外事件中,导致文件系统损坏的根本原因在于 ...
- FormsAuthentication.SetAuthCookie
这两天在研究 Forms 进行用户验证, 它本身没有什么上msdn上查一下就知道怎么个搞法了! 不过我在测试的时候发现也会产生 了一些疑问! 1. 什么我在web.config 的 authentic ...
- 【Servlet】Java Serlvet Filter 过滤器
Filter的设计思想Filter是一种AOP(aspect-oriented programming)的设计思想 : 面向切面编程.用于的请求和响应都会走 使用filter的登录案例我们通过一张图片 ...
- Swift 类型检查与类型转换
前言 在 Swift 语言中一般使用 is 关键字实现类型检查,使用 as 关键字实现类型转换,除此之外还可以通过构造器和方法来实现类型转换. 1.类型检查 1.1 使用 is 检查 类型检查操作符 ...
- Mac 重建 Spotlight 索引
前言 最近发现很多 mac 用户反映自己的 mac 系统显示内存占用高达 200 多 Gb,可是实际上自己下载的应用程序根本没那么多,使用专业的内存扫描工具扫的结果跟系统本身显示的完全不一样.那么出现 ...
- numpy 的通用函数
1 CSV文件 CSV,Comma Separate Values,是逗号分隔文件的缩写,是一种存储数据的纯文本格式,通常用于存储电子表格或数据库软件 特点 每条记录占一行 以逗号为分隔符 逗号前后的 ...
- SharePoint 2013混合模式登陆中 使用 自定义登陆页
接前一篇博客<SharePoint 2013自定义Providers在基于表单的身份验证(Forms-Based-Authentication)中的应用>,当实现混合模式登陆后,接着我们就 ...
- html5 audio组件禁止下载
参考链接:https://wdd.js.org/audio-hide-download-icon.html 1. controlsList=”nodownload”// 这个方法只支持 Chrome ...