CU Install
CU Install
CU Install
//
// Microsoft provides programming examples for illustration only,
// without warranty either expressed or implied, including, but not
// limited to, the implied warranties of merchantability and/or
// fitness for a particular purpose.
//
// This sample assumes that you are familiar with the programming
// language being demonstrated and the tools used to create and debug
// procedures. Microsoft support professionals can help explain the
// functionality of a particular procedure, but they will not modify
// these examples to provide added functionality or construct
// procedures to meet your specific needs. If you have limited
// programming experience, you may want to contact a Microsoft
// Certified Partner or the Microsoft fee-based consulting line at
// (800) 936-5200 .
//
// For more information about Microsoft Certified Partners, please
// visit the following Microsoft Web site:
// https://protect-au.mimecast.com/s/MXJqClxwGLIOoYvmiG1LaY?
domain=partner.microsoft.com
//
// Author: Russ Maxwell (russmax@microsoft.com)
//
// ---------------------------------------------------------- #>
###########################
##Ensure Patch is Present##
###########################
$patchfile = Get-ChildItem | where{$_.Extension -eq ".exe"}
if($patchfile -eq $null)
{
Write-Host "Unable to retrieve the file. Exiting Script" -ForegroundColor Red
Return
}
########################
##Stop Search Services##
########################
##Checking Search services##
$srchctr = 1
$srch4srvctr = 1
$srch5srvctr = 1
elseif($searchappresult -eq 2)
{
Write-Host "Continuing without pausing the Search Service Application"
}
else
{
Write-Host "Run the script again and choose option 1 or 2" -ForegroundColor
Red
Write-Host "Exiting Script" -ForegroundColor Red
Return
}
}
do
{
$srv6 = get-service "SPSearchHostController"
if($srv6.status -eq "Stopped")
{
$yes = 1
}
Start-Sleep -seconds 10
}
until ($yes -eq 1)
#######################
##Stop Other Services##
#######################
Set-Service -Name "IISADMIN" -startuptype Disabled
Set-Service -Name "SPTimerV4" -startuptype Disabled
Write-Host "Gracefully stopping IIS W3WP Processes" -foregroundcolor yellow
Write-Host
iisreset -stop -noforce
Write-Host "Stopping Services" -foregroundcolor yellow
Write-Host
##################
##Start patching##
##################
Write-Host "Patching now keep this PowerShell window open" -ForegroundColor Magenta
Write-Host
$starttime = Get-Date
$filename = $patchfile.basename
$arg = "/passive"
Start-Sleep -seconds 20
$proc = get-process $filename
$proc.WaitForExit()
$finishtime = get-date
Write-Host
Write-Host "Patch installation complete" -foregroundcolor green
Write-Host
##################
##Start Services##
##################
Write-Host "Starting Services Backup" -foregroundcolor yellow
Set-Service -Name "SPTimerV4" -startuptype Automatic
Set-Service -Name "IISADMIN" -startuptype Automatic