切换到宽版
  • 7638阅读
  • 0回复

[求助]CustomPatchInstallerActions-Sample [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2011-08-24
— 本帖被 YOYO 从 Exchange 脚本中心 移动到本区(2015-06-25) —
  • 脚本环境:PowerShell
  • 适合版本:Exchange 2007
  • 适用平台:
  • 脚本作用:Script to register custom commands to stop and restart services and provide a way to avoid unnecessary reboots of the computer after update rollup installations.
#################################################################################
#  
# The sample scripts are not supported under any Microsoft standard support  
# program or service. The sample scripts are provided AS IS without warranty  
# of any kind. Microsoft further disclaims all implied warranties including, without  
# limitation, any implied warranties of merchantability or of fitness for a particular  
# purpose. The entire risk arising out of the use or performance of the sample scripts  
# and documentation remains with you. In no event shall Microsoft, its authors, or  
# anyone else involved in the creation, production, or delivery of the scripts be liable  
# for any damages whatsoever (including, without limitation, damages for loss of business  
# profits, business interruption, loss of business information, or other pecuniary loss)  
# arising out of the use of or inability to use the sample scripts or documentation,  
# even if Microsoft has been advised of the possibility of such damages
#
#################################################################################

###############################################################################
# Copyright (c) 2005 Microsoft Corporation.  All rights reserved.
#
# CustomPatchInstallerActions.ps1.template
#

###############################################################################
# Location of folder of log actions performed by the script, to help with troubleshooting
#
$script:logDir = "$env:SYSTEMDRIVE\ExchangeSetupLogs"

###############################################################################
# Log( $entry )
#             Add an entry to the log file
#             Append a string to a well-known text file with a time stamp
# Params:
#             Args[0] - Entry to write to log
# Returns:
#             void
function Log
{
                $entry = $Args[0]

                $line = "[{0}] {1}" -F $(get-date).ToString("HH:mm:ss"), $entry
                add-content -Path "$script:logDir\CustomPatchInstallerActions.log" -Value $line
}

###############################################################################
#
# PatchRollbackActions
# Include items to run for rollback here
#
function PatchRollbackActions
{
                Log "Running PatchRollbackActions"
}

###############################################################################
#
# PrePatchInstallActions
# Include items to run before the patch here
#
function PrePatchInstallActions
{
                Log "Running PrePatchInstallActions"
}

###############################################################################
#
# PostPatchInstallActions
# Include items to run after the patch here
#
function PostPatchInstallActions
{
                Log "Running PostPatchInstallActions"
}

###############################################################################
#
# Main function
# Installer will call the cript with the following options
#
switch ($Args[0])
{

                {$_ -ieq "PrePatchInstallActions" }
                {

                                PrePatchInstallActions
                                break
                }

                {$_ -ieq "PostPatchInstallActions" }
                {
                                PostPatchInstallActions
                                break
                
                }

                {$_ -ieq "PatchRollbackActions"}
                {

                                PatchRollbackActions
                                break
                }
}

Exit 0
分享到
快速回复
限60 字节
 
上一个 下一个