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 ...
随机推荐
- 蛋疼的经历--wireshark不能启动的问题
事情是这样子的,最近新入职,安装了wireshark,,,在急需要其观察数据包结构,,,,写代码时,,,,卡了,,,我的天!!! 刚开始是提示说,找不到动态链接库api-ms-win-crt-runt ...
- Linux如何实现开机启动程序详解(转)
Linux开机启动程序详解我们假设大家已经熟悉其它操作系统的引导过程,了解硬件的自检引导步骤,就只从Linux操作系统的引导加载程序(对个人电脑而言通常是LILO)开始,介绍Linux开机引导的步骤. ...
- magento 为用户注册增加一个字段(转)
步骤 I. 加一个occupation/title字段到用户注册页,差不多在register.html的54行,在email下方加一个Occupation显示代码 代码: <li>< ...
- golang学习笔记 ---TCMalloc
图解 TCMalloc 前言 TCMalloc 是 Google 开发的内存分配器,在不少项目中都有使用,例如在 Golang 中就使用了类似的算法进行内存分配.它具有现代化内存分配器的基本特征:对抗 ...
- ASP.NET MVC 向浏览器发送文件以提供文件下载功能
撑到大三了,结果发现周围的同学更加堕落了,尤其是某些人,表面上看起来很认真,实际上三天打鱼,两天晒网,结果一事无成,却还要抱怨学校教育失败. 为了吸取他们的教训,就算是一个小小的编码问题,我也要努力解 ...
- Oracle 12C -- truncate的级联操作
在之前的版本中,存在外键约束时,无法直接truncate父表.在12C中,对truncate操作添加了级联操作特性. 前提是创建外键约束时,使用了"on delete casacde&quo ...
- STM8在IAR中Option Byte配置
转http://www.stmcu.org/module/forum/thread-607140-1-1.html 近期帮客户调试STM8的程序使用到OptionByte配置,在网上查询几乎都是介绍如 ...
- Oracle in和exists效率问题分析
--------------------------in和exists效率问题------------- 单说in和exsist,in的效率较差.关于EXISTS与IN的区别:EXISTS检查是否有结 ...
- eclipse 反编译插件 jadclipse
1. 下载 JadClipse 下载JadClipse:http://jadclipse.sourceforge.net/wiki/index.php/Main_Page#Download 注意选择与 ...
- git忽略除指定文件/指定后缀名文件外的文件
不需要从头写.gitignore文件,GitHub已经为我们准备了各种配置文件,只需要组合一下就可以使用了.所有配置文件可以直接在线浏览:https://github.com/github/gitig ...