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.
This is a CustomPatchInstallerActions-Sample script. It goes with the following blog post:
http://msexchangeteam.com/archive/2010/06/02/455063.aspx
Script
#################################################################################
#
# 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
################################################################################# # # 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