powershell PowerShell脚本为SDL Web 8.1.1安装修补程序XPM_8.1.1.571

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell脚本为SDL Web 8.1.1安装修补程序XPM_8.1.1.571相关的知识,希望对你有一定的参考价值。

# This script will apply hotfix XPM_8.1.1.3571 for SDL Web 8.1.1
# Tested on SDL Web 8.1.1. Probably works in a comparable way with hotfix 3571 for SDL Web 8.5 and SDL Tridion 2013 SP1

# To install the hotfix...
# - make sure you have a backup of the SDL Web Content Manager which is located in the %TRIDION_HOME% path.
# - this script will make a backup of the files it touches (it copies .old files), see the filenames in the scripts output verbose messages
# - if you run the script again it will overwrite those backup files.
# - get a copy of the hotfix, unzip it to a folder and set the path to that folder in $hotfixSource
# - run the script
# - restart the application pool for "SDL Tridion" or restart IIS
# - test if the SDL Web CME is still working
# - clean up the .old files created by the installer

# Todo; nice to haves for this script
# - script parameters for hotfix source and verbose
# - -Whatif implementation to be able to explore the script without doing any changes
# - -Confirm to require confirmation before doing changes
# - unpack the hotfix zip, in a PowerShell 4 safe way

# Unpack the hotfix.zip and set the unzip path in $hotfixSource below. This is the only configuration parameter.
$hotfixSource = "C:\Install\SDL\Hotfix\XPM_8.1.1.3571"

# only continue if you know what you are doing...
exit


## I don't always make errors but when I do I stop
$ErrorActionPreference = "Stop"

## Set some file locations, no need to change those, those files are either coming from the Tridion installation, or from the hotfix 
$quickCheckFile = Join-Path $env:TRIDION_HOME "\web\WebUI\Editors\Safeguard\Scripts\quickcheck.js"
$quickCheckSourceFile = Join-Path $hotfixSource "quickcheck.js"

$contentScriptFile = Join-Path $env:TRIDION_HOME "\web\WebUI\Editors\Safeguard\Scripts\ContentScript.js"
$contentScriptSourceFile = Join-Path $hotfixSource "ContentScript.js"

$safeguardDllFile = Join-Path $env:TRIDION_HOME "\web\WebUI\WebRoot\bin\Tridion.Web.UI.Models.Safeguard.dll"
$safeguardDllSourceFile = Join-Path $hotfixSource "Tridion.Web.UI.Models.Safeguard.dll"

$safeguardEditorConfigFile = Join-Path $env:TRIDION_HOME "\web\WebUI\Editors\Safeguard\Configuration\SafeguardEditor.config"

$safeguardModelConfigFile = Join-Path $env:TRIDION_HOME "\web\WebUI\Models\Safeguard\Configuration\SafeguardModel.config"

$systemConfigFile = Join-Path $env:TRIDION_HOME "\web\WebUI\WebRoot\Configuration\System.config"

## Before doning any changes, check if all the files we need to touch are present
function AssertPathPrerequisite ($path)
{
    if(!(Test-Path $path))
    {
        Write-Error ("Could not find {0}" -f $path)
    }
}

AssertPathPrerequisite $hotfixSource 

AssertPathPrerequisite $quickCheckFile
AssertPathPrerequisite $quickCheckSourceFile

AssertPathPrerequisite $contentScriptFile
AssertPathPrerequisite $contentScriptSourceFile

AssertPathPrerequisite $safeguardDllFile
AssertPathPrerequisite $safeguardDllSourceFile

AssertPathPrerequisite $safeguardEditorConfigFile

AssertPathPrerequisite $safeguardModelConfigFile

AssertPathPrerequisite $systemConfigFile

# Apply the hotfix, copying a backup of each file before applying the hotfix.
Move-Item $quickCheckFile ($quickCheckFile + ".old") -Verbose
Copy-Item $quickCheckSourceFile $quickCheckFile -Verbose

Move-Item $contentScriptFile ($contentScriptFile + ".old") -Verbose
Copy-Item $contentScriptSourceFile $contentScriptFile -Verbose

Move-Item $safeguardDllFile ($safeguardDllFile + ".old") -Verbose
Copy-Item $safeguardDllSourceFile $safeguardDllFile -Verbose

Copy-Item $safeguardEditorConfigFile ($safeguardEditorConfigFile + ".old") -Verbose
[xml] $safeguardEditorConfig = Get-Content $safeguardEditorConfigFile
$safeguardEditorConfig.Configuration.settings.customconfiguration.clientconfiguration.contextURL = "http://dqm.crownpeak.com/safeguard"
$safeguardEditorConfig.Save((Resolve-Path $safeguardEditorConfigFile))

Copy-Item $SafeguardModelConfigFile ($SafeguardModelConfigFile + ".old") -Verbose
[xml] $safeguardModelConfig = Get-Content $safeguardModelConfigFile
$safeguardModelConfig.Configuration.settings.customconfiguration.ActiveStandardsServiceUrl = "https://api.crownpeak.net/dqm-cms/v1/"
$safeguardModelConfig.Save((Resolve-Path $SafeguardModelConfigFile))

Copy-Item $systemConfigFile ($systemConfigFile + ".old") -Verbose
[xml] $systemConfig = Get-Content $systemConfigFile
if(!([int] $systemConfig.Configuration.servicemodel.server.modification -gt 0))
{
    Write-Error ("Unexpeted value for Configuration\servicemodel\server\modification in {0}" -f $systemConfigFile)
}
$systemConfig.Configuration.servicemodel.server.modification = ([int] $systemConfig.Configuration.servicemodel.server.modification + 1).ToString()
$systemConfig.Save((Resolve-Path $systemConfigFile))

## Done
Write-Host "Done. Now recycle the SDL Web application pool or restart IIS"
Write-Host "Remember to clean up the .old files"

以上是关于powershell PowerShell脚本为SDL Web 8.1.1安装修补程序XPM_8.1.1.571的主要内容,如果未能解决你的问题,请参考以下文章

powershell 为Powershell脚本模糊密码

Powershell命令等待一段时间

powershell 将执行策略远程签名设置为信任powershell脚本

如何在 PowerShell 中使用 S/MIME 对消息进行签名和加密

为自动执行设置 PowerShell 脚本

powershell 用于将WebVTT转换为SRT的Windows PowerShell脚本